my plot shows nothing! any suggestion would be appreciated. I know i can use bode() and tf, but i wanna do it in this way. thanks
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
ocsse
am 28 Nov. 2017
Beantwortet: Star Strider
am 28 Nov. 2017
syms w
% Resistor = 1000 Ohm
ZR = 1e3;
% Inductor = 100 mH
ZL = 100e-3;
% Capacitor = 500 microF
ZC = 500e-6;
for w = 200*pi:2000*pi
%transfer function
H = 100 * ( 1j*w / ( 1j*w + ( 1 / (ZR*ZC) ) ) );
%gain
gain_dB = mag2db(real(H))
%phase
phase = angle(H);
end
%frequency
fr_Hz = linspace(100,1000);
% plot the gain
figure(1)
plot(fr_Hz,gain_dB)
title('Bode Plot Gain')
xlabel('Frequency (Hz)')
ylabel('Gain (dB)')
% plot the phasor
figure(2)
plot(fr_Hz, phase)
title('Bode Plot (Phasor)')
xlabel('Frequency (Hz)')
ylabel('Phase (\circ)')
0 Kommentare
Akzeptierte Antwort
Star Strider
am 28 Nov. 2017
Save your variables to vectors by subscripting them:
w = 200*pi:2000*pi;
for k1 = 1:length(w)
%transfer function
H(k1) = 100 * ( 1j*w(k1) / ( 1j*w(k1) + ( 1 / (ZR*ZC) ) ) );
%gain
gain_dB(k1) = mag2db(real(H(k1)));
%phase
phase(k1) = angle(H(k1));
end
There is no need to use the Symbolic Math Toolbox here, and it will just slow things down. I leave the rest to you.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Classical Control Design finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!