Problem with the application GUIDE
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hi, i'm trying to plot a graph with implicits equations, this is my code :
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
a = str2num(get(handles.textbox1,'String'));
fh = @(S,M) (M-(1/a)*(a-S)+S);
gh = @(S,M) (M-S)*(a*(M-S)*((1-a)*((a*S)/(a+S))+((a*a)/(a+S).^2)*(a-S))-(a-S).^2*((a*a)/(a+S).^2));
hold on
w=ezplot(fh,[0,10,0,10])
x=ezplot(gh,[0,10,0,10])
and MATLAB answers me
Contour with properties:
LineColor: 'flat'
LineStyle: '-'
LineWidth: 0.5000
Fill: 'off'
LevelList: 0
XData: [1x251 double]
YData: [251x1 double]
ZData: [251x251 double]
Show all properties
Warning: Function failed to evaluate on array inputs; vectorizing the function may speed up its evaluation and avoid the
need to loop over array elements.
> In ezplotfeval (line 56)
In ezplot>ezimplicit (line 257)
In ezplot (line 153)
In aqwzsx>pushbutton1_Callback (line 111)
In gui_mainfcn (line 95)
In aqwzsx (line 42)
In @(hObject,eventdata)aqwzsx('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
x =
Contour with properties:
LineColor: 'flat'
LineStyle: '-'
LineWidth: 0.5000
Fill: 'off'
LevelList: 0
XData: [1x251 double]
YData: [251x1 double]
ZData: [251x251 double]
Show all properties
So i don't know how to solve this problem...
Moreover i would like how to plot this two graphes with differents colors someone knows how to do it ?
Thanks a lot !!!!
0 comentarios
Respuestas (1)
Walter Roberson
el 8 de Mayo de 2015
ezplot() passes in equal-length column vectors for the two arguments to the function. Your code is expecting scalar values. ezplot() will notice the problem and will fall back to working with scalars, but it gives a warning when it does so. It is not an error message, it is a warning that you could be more efficient.
In particular, rewrite as
gh = @(S,M) (M-S).*(a*(M-S).*((1-a)*((a*S)./(a+S))+((a*a)./(a+S).^2).*(a-S)) - (a-S).^2.*((a*a)./(a+S).^2));
1 comentario
Walter Roberson
el 8 de Mayo de 2015
To change the colors, use
set(w, 'LineColor', 'r'); %red
set(x, 'LineColor', [.2, .9, .3]) %random RGB triple
Ver también
Categorías
Más información sobre Annotations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!