MATLAB: How to program push button to request user input and insert it into array

clinical reportguiguidestructured array

I'm creating a GUI w/ two push back buttons: 'Existing Patient', and 'New Patient'. To program New Patient, I want the GUI to request user input for NAME and DOB, and insert it into an array. How do I do this?
My empty array:
patient(2).name={}; patient(2).dob={}; patient(2).date={}; patient(2).percentages={[]}; patient(2).notes={};

Best Answer

It all depends on whether you want the prompt within GUI or popup question to show up. Perhaps the function inputdlg() would work for the popup version.
example:
%once 'New Patient' has been selected (insert similar lines into the new patient pushbutton callback section)
prompt = {'Enter New Patient''s Name:','Enter Patient''s DOB:'};
% need to use double '' to get the single ' to show up in a string;
promptname = 'Entry for New Patient';
numlines = 1;
defaultanswer = {'Doe, John' , 'mm/dd/yyy'};
answer = inputdlg(prompt, promptname,numlines,defaultanswer);
%%insert into array
patient(2).name = answer(1);
patient(2).dob = answer(2);
% continue on-wards to get the rest of the process to enter the percentages or notes.
Now if the prompt is to be displayed within the same GUI interface, it gets a bit trickier, since the rest of the GUI is unknown to us. I would assume there would be some edit boxes for name and DOB. Just use the normal get() function For default GUIDE naming:
patient(2).name =get(handles.edit1,'String');
%where edit1 is the tag for the edit box where the new patient's name is to be entered.
patient(2).dob = get(handles.edit2,;'String');
%where edit2 is the tag for the edit box where the new patient's DOB is to be entered.