필터 지우기
필터 지우기

Error using subplot with App Designer

조회 수: 7 (최근 30일)
endystrike
endystrike 2020년 2월 27일
편집: Adam Danz 2020년 2월 27일
Hi everyone,
I'm continuously facing the error "Error using handle. Cannot convert to handle." when trying to plot different data into subplot in App Designer.
At the moment I coded the following code (those data works regularly if I plot them not in App Designer).
"bdays" and all other "dataN" variables are 398x1 double as format.
load('MyData.mat','-mat');
app.UI_Axes.AutoResizeChildren = 'off';
ax1 = subplot(10,1,[1 7],'Parent',app.UI_Axes);
plot(ax1,bdays,data1,'b');
hold(ax1,'on');
plot(ax1,bdays,data2,'r');
plot(ax1,bdays,data3,'c');
if (ShowOne)
plot(ax1,data4,'k');
end
ax2 = subplot(10,1,[8 10],'Parent',app.UI_Axes);
plot(ax2,bdays,data5,'b');
hold(app.UI_Axes,'on');
plot(ax2,bdays,data6,'r');
if (ShowOne)
plot(ax2,bdays,data7,'k');
end

채택된 답변

Adam Danz
Adam Danz 2020년 2월 27일
편집: Adam Danz 2020년 2월 27일
The parent of a subplot (ie, axes) should be a figure (or Panel objects, Tab object, or TiledChartLayout object). You're using another axis handles as the parent.
f = uifigure();
f.AutoResizeChildren = 'off';
subplot(2,2,1,'Parent',f)
Note: in appdesigner, the f variable will be the handle to the app figure.
I'm wondering why you need to add subplots to the app from within the code. Wouldn't it be more efficient to produce all of the axes from within the AppDesigner user interface and then control their visiblity?
  댓글 수: 1
endystrike
endystrike 2020년 2월 27일
Thank you very much, I'll do as you've suggested!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Subplots에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by