What value have a variable 'edit text' guide

1 回表示 (過去 30 日間)
Sergio
Sergio 2012 年 5 月 16 日
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

採用された回答

Geoff
Geoff 2012 年 5 月 16 日
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.
  1 件のコメント
Sergio
Sergio 2012 年 5 月 16 日
Thanks

サインインしてコメントする。

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2012 年 5 月 16 日
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.

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by