Borrar filtros
Borrar filtros

How to delete the text of the previous state

4 visualizaciones (últimos 30 días)
han han
han han el 2 de Jul. de 2020
Editada: Walter Roberson el 2 de Jul. de 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

Respuesta aceptada

Walter Roberson
Walter Roberson el 2 de Jul. de 2020
Editada: Walter Roberson el 2 de Jul. de 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])

Más respuestas (0)

Categorías

Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by