MATLAB: Inserting 2 digit number not as a matrix

MATLABmatrixmldivide

Hello, I'm currently making a gui in solving integral using trapezoidal rule. The gui input were a = min integral limit, and b = max intergral limit. However, when I keyed in the number of subintervals, matlab gives me and mldivide error. How can I key in not as a matrix but as a 2 digit number
% function varargout = Trapezoidal_rule(varargin)
% TRAPEZOIDAL_RULE MATLAB code for Trapezoidal_rule.fig
% TRAPEZOIDAL_RULE, by itself, creates a new TRAPEZOIDAL_RULE or raises the existing
% singleton*.
%




% H = TRAPEZOIDAL_RULE returns the handle to a new TRAPEZOIDAL_RULE or the handle to
% the existing singleton*.
%
% TRAPEZOIDAL_RULE('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in TRAPEZOIDAL_RULE.M with the given input arguments.
%
% TRAPEZOIDAL_RULE('Property','Value',...) creates a new TRAPEZOIDAL_RULE or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before Trapezoidal_rule_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to Trapezoidal_rule_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help Trapezoidal_rule
% Last Modified by GUIDE v2.5 09-Apr-2013 23:26:20
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Trapezoidal_rule_OpeningFcn, ...
'gui_OutputFcn', @Trapezoidal_rule_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before Trapezoidal_rule is made visible.
function Trapezoidal_rule_OpeningFcn(hObject, ~, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure

% eventdata reserved - to be defined in a future version of MATLAB













% handles structure with handles and user data (see GUIDATA)








% varargin command line arguments to Trapezoidal_rule (see VARARGIN)
% Choose default command line output for Trapezoidal_rule
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes Trapezoidal_rule wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = Trapezoidal_rule_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in calculate.
function calculate_Callback(hObject, eventdata, handles)
% hObject handle to calculate (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
calculate = trapz(x,equation);
% --- Executes on button press in reset.
function reset_Callback(hObject, eventdata, handles)
% hObject handle to reset (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
function value_a_Callback(hObject, eventdata, handles)
% hObject handle to value_a (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_a as text
% str2double(get(hObject,'String')) returns contents of value_a as a double
handles.value_a = get (hObject,'string');
guidata (hObject, handles)
% --- Executes during object creation, after setting all properties.




function value_a_CreateFcn(hObject, eventdata, handles)
% hObject handle to value_a (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called




% Hint: edit controls usually have a white background on Windows.




% See ISPC and COMPUTER.




if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function value_b_Callback(hObject, eventdata, handles)
% hObject handle to value_b (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_b as text
% str2double(get(hObject,'String')) returns contents of value_b as a double
handles.value_b = get (hObject, 'string');
guidata (hObject, handles)
% --- Executes during object creation, after setting all properties.
function value_b_CreateFcn(hObject, eventdata, handles)
% hObject handle to value_b (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
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
handles.value_n = get (hObject, 'string');
n = handles.value_n
a = handles.value_a
b = handles.value_b
handles.h = (b-a)/n
h = handles.h
handles.x=a:h:b
x=handles.x
guidata (hObject, handles);
% --- Executes during object creation, after setting all properties.
function value_n_CreateFcn(hObject, eventdata, handles)
% hObject handle to value_n (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function equation_Callback(hObject, eventdata, handles)
% hObject handle to equation (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 equation as text
% str2double(get(hObject,'String')) returns contents of equation as a double
equation = get(hObject, 'string');
% --- Executes during object creation, after setting all properties.
function equation_CreateFcn(hObject, eventdata, handles)
% hObject handle to equation (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function answer_1_Callback(hObject, eventdata, handles)
% hObject handle to answer_1 (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 answer_1 as text
% str2double(get(hObject,'String')) returns contents of answer_1 as a double
answer_1 = get(calculate)
% --- Executes during object creation, after setting all properties.
function answer_1_CreateFcn(hObject, eventdata, handles)
% hObject handle to answer_1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
Thank you viewing this question and I thank you for any help provided

Best Answer

handles.value_n = str2double( get(hObject, 'string') );
... Just like the hint in the comment immediately above your original line.
Related Question