Problem with the application GUIDE
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Walter Roberson
2015-5-8
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 个评论
Walter Roberson
2015-5-8
To change the colors, use
set(w, 'LineColor', 'r'); %red
set(x, 'LineColor', [.2, .9, .3]) %random RGB triple
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!