How to delete a cell in gui

조회 수: 5 (최근 30일)
leydy Garcia
leydy Garcia 2020년 2월 18일
답변: Walter Roberson 2020년 2월 19일
Hi, I want to delete a line from a plot in GUI. To do that, I have created the following code:
line1=num2str(get(handles.plotHandles,'XData'));
delete(line1)
where line1 is composed of 2x1 cells = [ 1x2 double]
[1x2 double]
it seems something is wrong here but I cannot find the solution. I am getting the following error:
Any suggestion to fix this error?
Undefined function 'abs' for input arguments of type 'cell'.
Error in num2str (line 66)
xmax = double(max(abs(widthCopy(:))));
Error in Loading_Well_logs>pushbutton8_Callback (line 1931)
line1=num2str(get(handles.plotHandles,'XData'));
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in Loading_Well_logs (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)Loading_Well_logs('pushbutton8_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback

채택된 답변

Walter Roberson
Walter Roberson 2020년 2월 19일
When you get() a property from more than one graphic object, you get back a cell array in response. You are trying to use num2str on that cell, but cell cannot be converted to characters by num2str.
The Xdata associated with a line plot is the X coordinates in data units. You are taking the data units and trying to convert the coordinates to characters. Then you pass the characters to delete(). When you pass characters to delete() that is interpreted as a request to delete a file named by the characters.
If you want to remove graphics objects from display and memory
delete(handles.plothandles)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Object Properties에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by