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)')
댓글 수: 0
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Classical Control Design에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!