How to plot pzmap, nyquist plot and bode plot in App Designer
3 views (last 30 days)
Show older comments
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/611865/image.png)
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 Comments
Answers (1)
Shiva Kalyan Diwakaruni
on 13 May 2021
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 Comments
See Also
Categories
Find more on Stability Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!