How can I get multiple data(*text*) form single edit text in MATLAB guide?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have a GUI with several edit text and push buttons. a specific edit text which call Rx_name, i set edittext to 10, where user can enter different names.
What I want is to stor the data in one row
like
name=[name1 name2 name3 ....]
my code is
function pushbutton1_Callback(~, ~, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
Rx_name=get(handles.Rx_name,'String')
Rx_lat=str2num(char(get(handles.Rx_lat,'String')));
Rx_lon=str2num(char(get(handles.Rx_long,'String')));
Rx_height=str2num(char(get(handles.Rx_height,'String')));
rxs = rxsite('Name', Rx_name,...
'Latitude',Rx_lat,...
'Longitude',Rx_lon,...
'AntennaHeight',Rx_height);
show(rxs)
link(rxs,txs)
I got different values for Rx_lat, Rx_lon and Rx_height but I can't get different *text* for Rx_name wher it should be text not number
0 Kommentare
Antworten (1)
Drishan Poovaya
am 10 Aug. 2021
I understand you want to store your text data from an edit text input in one row.
This snippet which you have written
Rx_name=get(handles.Rx_name,'String')
wthis will store the entire edit text as one continuous string. Assume the edit text was name1 name2 name3, Rx_name will be ‘name1 name2 name3’, a single string.
In order to store them separately, you can use the split command
Rx_name_split = split(Rx_name)
, which splits at all white spaces.
The result Rx_name_split will be a cell array with name1,name2 and name3 stored as individual elements. You can index a cell array like this:
Rx_name_split{1}
or
Rx_name_split{2}
or so on
Docs:
https://www.mathworks.com/help/matlab/ref/split.html
Siehe auch
Kategorien
Mehr zu Migrate GUIDE Apps 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!