How to plot pzmap, nyquist plot and bode plot in App Designer
조회 수: 4 (최근 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!