Clear Filters
Clear Filters

Where does my impedance problem come from?

1 view (last 30 days)
damien bertein
damien bertein on 5 Jun 2018
Answered: Kim Winter on 3 Jul 2018
Good morning, I have a problem with my matlab code to plot my impedance module according to frequency. The problem is that I can't find my error despite the help of the documentation.
Here is my matlab code
if true
close all
clear all
pas = 10;
F= (0:pas:20000);
w= 2*pi*F;
x= w.^2;
Re= 9.54;
Le= 0.19;
Lem= 0.000011*5.07;
Rem= (5.07^2)/1.905;
Cem= 0.011/5.05;
Cer1= 5.07^2/(13.2*0.18);
Cer2= Cer1;
Z= Re+1i*w*Le+((1i*w*Lem)/(1+1i*w*(Lem/Rem)-(Cer1+Cer2+Cem)*Lem*x));
Fr= ((1/(2*pi))*(1/(Lem*(Cem+Cer1+Cer2))));
R=abs(Z);
f=(1:10:20000);
figure, loglog(f,R,'r');
xlabel('Fréquence', 'fontSize',15);
ylabel('Impédance acoustique Z', 'fontsize', 15);
end

Answers (1)

Kim Winter
Kim Winter on 3 Jul 2018
Hi, I believe that your issue is when you plot loglog. When you plot, for every x value, you should have a corresponding y value. If you check the lengths of f and R respectively, f is 2001 points and R is 2000 points. So, if instead, you plotted:
figure, loglog(f,R(2:end),'r');
or
figure, loglog(f,R(1:end-1),'r');
a figure will show.

Categories

Find more on Acoustics, Noise and Vibration in Help Center and File Exchange

Products


Release

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!