What value have a variable 'edit text' guide

1 visualización (últimos 30 días)
Sergio
Sergio el 16 de Mayo de 2012
What value have a variable 'edit text' in guide if the variable doesn't have any value in the interface......
T = str2num(get(handles.TM,'string'));
TM is a edit text in guide, but if TM doesn't have anything what value has? is for do the next:
T = str2num(get(handles.TM,'string'));
if T==[]
T=0.001;
end
I put [] but doesn't work

Respuesta aceptada

Geoff
Geoff el 16 de Mayo de 2012
No, you need to use isempty.
if isempty(T)
T = 0.001;
end
Note that if you use str2double instead, you'll get NaN and can use isnan to test.

Más respuestas (1)

Walter Roberson
Walter Roberson el 16 de Mayo de 2012
T = str2double(get(handles.TM, 'string'));
if isnan(T); T = 0.001; end;
Notice str2double() instead of str2num(): this is more secure and more predictable.

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by