How can I get the numbers from GUI edit text in the contex like (1,2,3) ?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Erdem Aktürk
am 7 Dez. 2022
Beantwortet: Walter Roberson
am 7 Dez. 2022
(get(handles.initial_point,'String'));
what should I add here ?
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 7 Dez. 2022
S = strtrim(get(handles.initial_point,'String'));
nums = str2double(regexp(S, '[\s,]+', 'split'))
This allows spaces and/or commas between the numbers so '1,2,3' and '1, 2, 3' and '1 2 3' would all be accepted.
As written it does not allow [] or () in the text. Also, if the user were to use '1,,3' trying to indicate that they want to skip the second value, then the code above would not notice that multiple commas had been used and would treat it the same as '1,3'
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Language Fundamentals 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!