How to insert a function into a push button
Show older comments
Hello, I'm trying to make a GUI for solving integral using trapezoidal rule. So far, I've done until the calculate push button which gives an error of
??? Undefined function or variable 'x'.
Error in ==> Trapezoidal_rule>calculate_Callback at 81
calculate = trapz(x,equation)
Error in ==> gui_mainfcn at 96
feval(varargin{:});
Error in ==> Trapezoidal_rule at 42
gui_mainfcn(gui_State, varargin{:});
Error in ==> @(hObject,eventdata)Trapezoidal_rule('calculate_Callback',hObject,eventdata,guidata(hObject))
??? Error while evaluating uicontrol Callback
However, in the m.file I've specified the x value as
function value_n_Callback(hObject, eventdata, handles)
% hObject handle to value_n (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of value_n as text
% str2double(get(hObject,'String')) returns contents of value_n as a double
value_n = get(hObject, 'string');
h = (value_b - value_a)/ (value_n);
x = value_a:h:value_b;
How do I overcome this?
Your help is greatly appreciated
Accepted Answer
More Answers (0)
Categories
Find more on Programming in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!