フィルターのクリア

Problem in plotting using semilogx() function

1 回表示 (過去 30 日間)
PVR
PVR 2014 年 10 月 19 日
編集済み: Rick Rosson 2014 年 10 月 19 日
I need to plot a graph between w(frequency) and Mdb(Magnitude in db) using semilogx() function for different values of w. The output of graph is null. It shows nothing and there are no errors displayed. Where did I go wrong.
R=zeros(1,10000);
I=zeros(1,10000);
Mag=zeros(1,10000);
Z=zeros(1,10000);
Y=zeros(1,10000);
Mdb=zeros(1,10000);
for *w* = 0.1:0.01:10
R=(256-(16*w^2))/((16-(w^2))^2+(10*w)^2);
I=-160*w/((16-w^2)^2+(10*w)^2);
Mag=sqrt(R^2+I^2);
Z=atan2(I,R);
Y=Z*180/pi;
*Mdb* =20*log10(Mag); *bold*
plot(w,Mdb,'g');
semilogx(w,Mdb);
end

採用された回答

Rick Rosson
Rick Rosson 2014 年 10 月 19 日
編集済み: Rick Rosson 2014 年 10 月 19 日
Vectorized code, no for-loop necessary:
w = 0.1:0.01:10;
R = (256-(16*w.^2))./((16-(w.^2)).^2+(10*w).^2);
I = -160*w./((16-w.^2).^2+(10*w).^2);
X = complex(R,I);
Mag = abs(X);
Mdb = 20*log10(Mag);
phi = angle(X)*180/pi;
figure;
ax(1) = subplot(2,1,1);
semilogx(w,Mdb);
grid on;
xlabel('Frequency');
ylabel('Magnitude in dB');
ax(2) = subplot(2,1,2);
semilogx(w,phi);
grid on;
xlabel('Frequency');
ylabel('Phase angle in degrees');
linkaxes(ax,'x');

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePlot Customization についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by