How can I get multiple data(*text*) form single edit text in MATLAB guide?

조회 수: 2 (최근 30일)
Mezgean Mohammad
Mezgean Mohammad 2021년 8월 4일
댓글: Mezgean Mohammad 2021년 8월 10일
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

답변 (1개)

Drishan Poovaya
Drishan Poovaya 2021년 8월 10일
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

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by