Help with error code for my GUI
显示 更早的评论
I'm currently creating a GUI that is able to graph a user defined function. You are also able to find the zero value at a point by clicking a button that that then activates ginput. The code for this is below.
if true
% code
[x,y]=ginput(1);
fct=@(x) get(handles.funct,'String');
zero=num2str(fzero(fct,x));
set(handles.edit8,'String',zero);
guidata(hObject,handles)
end
In this code handles.funct is the user defined function, and handles.edit8 is a edit box where the answer will be output. Now when i run this program for a function such as 'cos(x)' i get the following error code as well as the edit box displaying NaN
if true
% code
Operands to the || and && operators must be
convertible to logical scalar values.
Error in fzero (line 308)
elseif ~isfinite(fx) || ~isreal(fx)
Error in Matlabfinalproject>findzero_Callback (line
186)
zero=num2str(fzero(fct,x));
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in Matlabfinalproject (line 44)
gui_mainfcn(gui_State, varargin{:});
Error in
@(hObject,eventdata)Matlabfinalproject('findzero_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
end
Not having enough knowledge of how to debug this was wondering if anyone else could help me explain to me why i'm getting this code
2 个评论
Niklas Nylén
2014-4-11
What does the function fct look like? What is the value of x from ginput?
Stephen Hawkins
2014-4-16
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Creating, Deleting, and Querying Graphics Objects 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!