MATLAB: How we can take two or more times input from a single edit text in matlab

edit textMATLABmatlab functionmatlab guistatic texttext boxtext;

function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double
a = sprintf('Enter the value');
set(handles.text1,'string',a)
x = get(handles.edit1,'string')
a = sprintf('How many nodes?');
set(handles.text1,'string',a)
x = get(handles.edit1,'string')
Assalam-o-Alaikum! Actually, I want to enter many inputs but I've just one edit text box in my UI. I am doing all this using Matlab.
Look at the output:
The first message disappears quickly and the second one displayed, same is the case for the inputs.

Best Answer

Hello Muhammed,
I assume that this is on the same topic as your other question? I'd suggest deleting that one and only keeping this one, as this question is far more descriptive.
It seems that you would like to do the equivalent of:
x = input('Enter the first value: ','s');
y = input('Enter the second value: ','s');
only in a GUI, rather than the Command Window. You seem to need it to wait for the user to input a value before prompting for the next one and accepting their response.
The first issue that I see is that you are coding the setup for this in the callback of the edit box. I would recommend setting up the structure for this in the GUI start-up function, and then putting the reaction to input in the callbacks. The second issue is that you are displaying prompts one after another, and not allowing for user input between them.
If I were to structure it, I'd do something like this:
In the GUI startup function:
% Set up the text prompts, and for the collection of data
promptStr = {'Enter the value', 'How many nodes', ...};
answerStr = cell(size(promptStr));
promptIdx = 1;
dataGatheringStruct = struct('prompts', promptStr, ...
'answers', answerStr, ...
'idx', promptIdx);
% Store that information in the GUI
setappdata(handles.figure1, 'DataGatherStruct', dataGatheringStruct)
Then in the callback (either to the edit text box, or to another button):
% Get the data gathering information
dataGatheringStruct = getappdata(handles.figure1, 'DataGatheringStruct');
% Extract the current value of the edit box
dataGatheringStruct.answer{dataGatheringStruct.idx} = get(handles.edit1, 'String');
% Update the information to be ready for the next answer
dataGatheringStruct.idx = dataGatheringStruct.idx+1;
set(handles.text1, 'String', dataGatheringStruct.prompts{dataGatheringStruct.idx})
set(handles.edit1, 'String', '')
You can do your processing of the data the users give either in the callback (if you need to react right away), in the callback of some other button/control (if you want to react to it when the user requests to), or in the close request function (if you only want to react at the end).
Hope this helps give you a structure to work from.
-Cam