How to plot pzmap, nyquist plot and bode plot in App Designer
6 次查看(过去 30 天)
显示 更早的评论
I have this GUI that accepts values for K,a,b,c,d and n to change the transfer function. My step response plot works fine but my pzmap, nyquist plot and bode plot wont work. The error message says : Error using plot
Data cannot have more than 2 dimensions.
Kvalue=app.EntervalueforKEditField.Value;
avalue=app.EntervalueforaEditField.Value;
bvalue=app.EntervalueforbEditField.Value;
cvalue=app.EntervalueforcEditField.Value;
dvalue=app.EntervaluefordEditField.Value;
nvalue=app.EntervaluefornEditField.Value;
sexplaststring = "";
i=5;
while i>0
if(nvalue>0)
sexpstring = " 0";
sexplaststring= sexpstring + sexpstring;
nvalue = nvalue -1;
end
i = i -1;
end
nvalue = app.EntervaluefornEditField.Value;
if(nvalue==0)
strdenom = "1 " + int2str(cvalue + dvalue) +" "+ int2str(cvalue*dvalue);
end
if(nvalue==1)
strdenom = "1 " + int2str(cvalue + dvalue) + " " + int2str(cvalue*dvalue) +" 0";
else
strdenom = "1 " + int2str(cvalue + dvalue) + " " + int2str(cvalue*dvalue) + sexplaststring;
end
gs=tf([Kvalue*avalue Kvalue*bvalue], [str2num(strdenom)]);
[Gm,Pm,Wcg,Wcp]=margin(gs);
app.Gmvalpz.Text = num2str(Gm);
app.Pmvalpz.Text = num2str(Pm);
app.Wcgvalpz.Text = num2str(Wcg);
app.Wcpvalpz.Text = num2str(Wcp);
[z,p,k]=tf2zp([Kvalue*avalue Kvalue*bvalue],[str2num(strdenom)]);
[y,t]=pzmap(p,z);
plot(app.UIAxes,t,y);
0 个评论
回答(1 个)
Shiva Kalyan Diwakaruni
2021-5-13
Hi,
You are receiving this error message because the data that you are plotting is an array, which has 3 dimensions. You can only plot data with two dimensions or less (e.g., a vector or a matrix).
Remove the extra singleton dimension in your data with the SQUEEZE function. For example The SQUEEZE function turns the 1x1x50 array into a 50x1 array that you can then plot.
refer to the below link
Hope it helps
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Plot Customization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!