필터 지우기
필터 지우기

Problem with the application GUIDE

조회 수: 1 (최근 30일)
abc abc
abc abc 2015년 5월 8일
댓글: Walter Roberson 2015년 5월 8일
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 !!!!

답변 (1개)

Walter Roberson
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
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 CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by