adding elements into a vector using MATLAB GUI
Afficher commentaires plus anciens
I am new to matlab and I'm trying to make a progrem which gets parameters from the user(using gui)for x value and y value,puts them into 2 different vectors and when the user is done it uses plot to make a graph out of the two vectors.
here is what I tries to do:
function pushbutton1_Callback(hObject, eventdata, handles)
x=[];
y=[];
a=str2double(get(handles.edit1,'string'));
b=str2double(get(handles.edit2,'string'));
handles.x=[x a];
handles.y=[y b];
guidata(hObject, handles);
function Doit_Callback(hObject, eventdata, handles)
axes(handles.axes1)
handles.x;
handles.y;
handles.m=handles.x;
handles.n=handles.y;
plot(handles.m,handles.n);
guidata(hObject, handles);
function Doit_Callback(hObject, eventdata, handles)
axes(handles.axes1)
handles.x;
handles.y;
handles.m=handles.x;
handles.n=handles.y;
plot(handles.m,handles.n);
guidata(hObject, handles);
but the plot function won't work.I'm tring to get a and b from the edit text in the gui and put them into vector x and vector y,and when I'm done adding all the element I want I'm trying to use the full vectors in the Doit function. any help would be appreciated
2 commentaires
Walter Roberson
le 28 Fév 2018
Are a and b intended to be vectors? Because str2double() only works for strings representing scalars. If this is the problem then str2num() works on strings representing scalars -- but is more fragile and less secure, since it is happy to accept input such as
delete('*.*')
and act on it...
elizabeth march
le 28 Fév 2018
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Workspace Variables and MAT Files dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!