problem is that it can not plot x and y,(
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
IN GUI,i define handles.matricdata.a=1 in pushbutton1 callback function.
then in pushbutton2 callback function i use
b=handles.matricdata.a;
if(b~=1)
x=[1 2 3 4 5];
y=[5 5 5 5 5]
plot(x,y);
end
then problem is that it can not plot x and y,(if pushbutton1 is not press,then x and y must be plot )
0 Kommentare
Akzeptierte Antwort
Azzi Abdelmalek
am 3 Mär. 2013
You should write in opening function
handles.matricdata.a=0
5 Kommentare
Azzi Abdelmalek
am 3 Mär. 2013
In your yourfilename_OpeningFcn
handles.metricdata.a=0;
guidata(hObject,handles)
Weitere Antworten (1)
Image Analyst
am 3 Mär. 2013
Now why would that not plot when you just set the value to 0 and you're checking if it's not equal to 1. It must go into the if statement. But this is bad code in several ways. What's the point of setting it to 1 in pushbutton1's callback? Why have an "if" in pushbutton2's callback when you directly assign it so you know what the state will be? The if is not necessary in that case. Why do you multiply y by 5? Think about it. If you don't enter the "if" then y will be undefined and it will throw an error. (Though I've already said that you will enter the if because of strange coding.) So in that case, just set y = [25 25 25 25 25] and be done with it.
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!