How I input an array of numbers in GUI text box?

10 ビュー (過去 30 日間)
Indu S
Indu S 2020 年 3 月 12 日
回答済み: Alex Mcaulley 2020 年 3 月 12 日
I want to enter an array of numbers in the TEXTBOX in GUI. In my code I'm converting the array of strings to array of numbers.
In the textbox when I give input as- [1 2 3 4 5].
After using
x=str2double(get(handles.edit1,'string'));
Im getting x Nan.
and get(handles.edit1,'string') = '[1 2 3 4 5]'.
What I want is x=[1,2,3,4,5]. Please suggest a solution. Thanks in advance

回答 (1 件)

Alex Mcaulley
Alex Mcaulley 2020 年 3 月 12 日
Use str2num instead:
x=str2num(get(handles.edit1,'string'));

カテゴリ

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