Set default value textedit
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MARIA RODRIGUEZ SANZ
am 23 Jul. 2018
Kommentiert: MARIA RODRIGUEZ SANZ
am 23 Jul. 2018
Hello,
I am new in GUI. I have created some GUI script in order to process images that contains the following syntax:
function Num_seg_Callback(hObject, eventdata, handles)
numseg=str2double(get(hObject,'String'));
if isempty(numseg) %I have also tried isnan
numseg=1;
end
handles.numseg=numseg;
guidata(hObject,handles);
I would like to set 1 as the default value of a text edit object (numseg) which I use below in my code. This syntax is giving an error (Reference to non-existent field 'numseg') and it works only if I first write a number and then delete it. Does anyone have an idea of why is this occurring? Why it doesn't work the first time I run it?
I have also tried: if isnan(numseg) set (handles.numseg,'String',1); end ...
3 Kommentare
Akzeptierte Antwort
Rik
am 23 Jul. 2018
In your OpeningFcn, you need to set a value for the numseg field. That way, the field exists in your handles struct and that other function can use it.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Workspace Variables and MAT Files 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!