フィルターのクリア

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 回表示 (過去 30 日間)
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)')

採用された回答

Star Strider
Star Strider 2017 年 11 月 28 日
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 件)

カテゴリ

Help Center および File ExchangeClassical Control Design についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by