How to delete the text of the previous state
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
han han
am 2 Jul. 2020
Bearbeitet: Walter Roberson
am 2 Jul. 2020
I want to implement an input UE ID (edit1) will display text on axes.
But I want to have only one text on axes.
For example: I entered UE ID 5 and pressed pushbutton, and then entered UE ID 6 and pressed pushbutton. When axes only displayed the text of UE ID 6.
function varargout = untitled(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @untitled_OpeningFcn, ...
'gui_OutputFcn', @untitled_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before untitled is made visible.
function untitled_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% --- Outputs from this function are returned to the command line.
function varargout = untitled_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
function pushbutton2_Callback(hObject, eventdata, handles)
[UElocation] = textread('observe/mdUELocationforGUI2.txt');
InputUEID = get(handles.edit1,'String');
InputUEID2 = str2double(InputUEID);
InputUEID3 = InputUEID2+1;
axes(handles.axes1)
c = string(InputUEID);
x3 = text(UElocation(InputUEID3,2), UElocation(InputUEID3,3), c,'FontSize',16);
axis([0 120 0 120])
function edit1_Callback(hObject, eventdata, handles)
function edit1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 2 Jul. 2020
Bearbeitet: Walter Roberson
am 2 Jul. 2020
function pushbutton2_Callback(hObject, eventdata, handles)
[UElocation] = textread('observe/mdUELocationforGUI2.txt');
InputUEID = get(handles.edit1,'String');
InputUEID2 = str2double(InputUEID);
InputUEID3 = InputUEID2+1;
ax = handles.axes1;
delete(findobj(ax.Children, 'flat', 'type','text')); %delete previous text if any
c = string(InputUEID);
x3 = text(ax, UElocation(InputUEID3,2), UElocation(InputUEID3,3), c,'FontSize',16);
axis(ax, [0 120 0 120])
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Graphics Object Programming finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!