필터 지우기
필터 지우기

Why does the Line Handle Become a Deleted Line Handle in App Designer?

조회 수: 27 (최근 30일)
I am developing an app that plots performance data in real-time. As part of the app, I have a set of axes to plot 7 lines for different data values whose visibility is controlled by checkbox elements. To control the visibility of the lines, I have callback functions to change the visibility property of each line depending on the checkbox value. However, when I try to control the line properties, I get an error message because the line handle shows as a deleted object. I set public properties for each line handle and when the app opens I have a function that creates a blank plot so the line handle is created and nonempty, and the properties are able to be changed.
function CreateBlankPlot(app)
app.discardsplot = plot(app.UIAxes,datetime('now'),0);
app.retriesplot = plot(app.UIAxes,datetime('now'),0);
app.failsplot = plot(app.UIAxes,datetime('now'),0);
app.recievedplot = plot(app.UIAxes,datetime('now'),0);
app.sentplot = plot(app.UIAxes,datetime('now'),0);
app.RSSIPlot = plot(app.UIAxes,datetime('now'),0);
app.SNRPlot = plot(app.UIAxes,datetime('now'),0);
set(app.discardsplot,'LineStyle','-','Color','green','Marker','o','MarkerFaceColor','green','Visible','off');
set(app.retriesplot,'Visible','off','LineStyle','-','Color','blue','Marker','o','MarkerFaceColor','blue');
set(app.failsplot,'Visible','off','LineStyle','-','Color','red','Marker','o','MarkerFaceColor','red');
set(app.recievedplot,'Visible','off','LineStyle','-','Color','black','Marker','o','MarkerFaceColor','black');
set(app.sentplot,'Visible','off','LineStyle','-','Color','yellow','Marker','o','MarkerFaceColor','yellow');
set(app.RSSIPlot,'Visible','off','LineStyle','-','Color','cyan','Marker','o','MarkerFaceColor','cyan');
set(app.SNRPlot,'Visible','off','LineStyle','-','Color','magenta','Marker','o','MarkerFaceColor','magenta');
end
When I run the code, I get an error message:
Error using matlab.graphics.chart.primitive.Line/set
Invalid or deleted object.
Error in Wifi_Performance_Tool/CreateBlankPlot (line 234)
set(app.discardsplot,'LineStyle','-','Color','green','Marker','o','MarkerFaceColor','green','Visible','off');
Error in Wifi_Performance_Tool/startupFcn (line 255)
CreateBlankPlot(app);
Error in Wifi_Performance_Tool (line 612)
runStartupFcn(app, @startupFcn)
When using breakpoints to diagnose the issue, I see that the line handle shows as a deleted object. However, if I type the same plot command that is in the function into the command window, then the line handle no longer is a deleted object, as shown below.
234 set(app.discardsplot,'LineStyle','-','Color','green','Marker','o','MarkerFaceColor','green','Visible','off');
K>> app.discardsplot
ans =
handle to deleted Line
K>> app.discardsplot = plot(app.UIAxes,datetime('now'),0)
K>> app.discardsplot
ans =
Line with properties:
Color: [0 0.4470 0.7410]
LineStyle: '-'
LineWidth: 0.5000
Marker: 'none'
MarkerSize: 6
MarkerFaceColor: 'none'
XData: 19-Jun-2021 15:42:11
YData: 0
ZData: [1×0 double]
Show all properties
Can someone please explain why the line handle is a deleted object when I run the code in App Designer, but when I run code in the command window, it works as expected?

채택된 답변

Walter Roberson
Walter Roberson 2021년 6월 19일
you do not have hold turned on so the second plot() removes the first, third removes the second, and so on.
The primative that skips checking holds is to use line() with all name/value pairs
  댓글 수: 1
Nick Nauman
Nick Nauman 2021년 6월 19일
Thank you very much! This solved the issue. Sorry for my blatant oversight.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by