In my gui,i have a popup menu where the user selects size of array.In the edit box below there is an edit box in which user enters a scalar entry & presses enter,then the next entry that he types at that edit box should be stored as 2nd entry of a vector & so on.
Example:-
- If user enters 100 at editbox --- array value = [100]
- next user enters 200 at editbox --- array value = [100 200]
- ....so on.
- If user exceeds size as set in popup --- array value = [].
My code:-
assignin('base','i',1);
assignin('base','array',[]);
i = evalin('base',i);
array = evalin('base','array');
size = get(handles.popup1,'User Data');
if length(array) < size
array(i) = str2double(get(hObject,'String'));
i = i+1;
assigin('base','i',i);
assigin('base','array',array);
else
assigin('base','array',[]);
assigin('base','i',1);
errordlg('Size Exceeded','Error');
end
Is there any better way to do this ?Without referencing to the base workspace each time ?