Matlab does not plot the function

조회 수: 1 (최근 30일)
Inés Bodoque
Inés Bodoque 2021년 1월 16일
댓글: Inés Bodoque 2021년 1월 17일
I'm trying to plot this function. There is no syntaxis mistakes, but the graphic appears empty. (It is a bode diagram).
GH_num= [1 2 3];
GH_den= [4 5 6 7 8];
GH_w=[];
for w=2*pi*logspace(-1,3,1000)
GH_num_w=polyval(GH_num,w*j);
GH_den_w=polyval(GH_den,w*j);
GH_w=[GH_w,GH_num_w/GH_den_w];
end
mag = 20*log10(abs(GH_w));
phase=rad2deg(angle(GH_w));
fGH=figure;
aGH=subplot(2,1,1,'Parent'fGH);
bGH=subplot(2,1,2,'Parent'fGH);
semilogx=(aGH,w/2/pi,mag)
semilogx=(bGH,w/2/pi,phase)

채택된 답변

Walter Roberson
Walter Roberson 2021년 1월 17일
GH_num= [1 2 3];
GH_den= [4 5 6 7 8];
GH_w=[];
wvals = 2*pi*logspace(-1,3,1000); %NEW
for w = wvals %CHANGED
GH_num_w=polyval(GH_num,w*j);
GH_den_w=polyval(GH_den,w*j);
GH_w=[GH_w,GH_num_w/GH_den_w];
end
mag = 20*log10(abs(GH_w));
phase=rad2deg(angle(GH_w));
fGH=figure;
aGH=subplot(2,1,1,'Parent',fGH); %FIXED
bGH=subplot(2,1,2,'Parent',fGH); %FIXED
semilogx(aGH,wvals/2/pi,mag) %FIXED
semilogx(bGH,wvals/2/pi,phase) %FIXED

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by