0% found this document useful (0 votes)
12 views4 pages

Funcional Simpsom13

Numericos

Uploaded by

dalmiro duarte
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views4 pages

Funcional Simpsom13

Numericos

Uploaded by

dalmiro duarte
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

function varargout = simpson13GUI(varargin)

% SIMPSON13GUI MATLAB code for simpson13GUI.fig


% SIMPSON13GUI, by itself, creates a new SIMPSON13GUI or raises the existing
% singleton*.
%
% H = SIMPSON13GUI returns the handle to a new SIMPSON13GUI or the handle to
% the existing singleton*.
%
% SIMPSON13GUI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in SIMPSON13GUI.M with the given input arguments.
%
% SIMPSON13GUI('Property','Value',...) creates a new SIMPSON13GUI or raises
the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before simpson13GUI_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to simpson13GUI_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 simpson13GUI

% Last Modified by GUIDE v2.5 10-Jun-2024 01:01:04

% Begin initialization code - DO NOT EDIT


gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @simpson13GUI_OpeningFcn, ...
'gui_OutputFcn', @simpson13GUI_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 simpson13GUI is made visible.


function simpson13GUI_OpeningFcn(hObject, eventdata, 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 simpson13GUI (see VARARGIN)

% Choose default command line output for simpson13GUI


handles.output = hObject;

% Update handles structure


guidata(hObject, handles);

% UIWAIT makes simpson13GUI wait for user response (see UIRESUME)


% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.
function varargout = simpson13GUI_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 calcularButton.


function calcularButton_Callback(hObject, eventdata, handles)
% hObject handle to calcularButton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

a = str2double(get(handles.ingresarLimiteAButton, 'String'));
b = str2double(get(handles.ingresarLimiteBButton, 'String'));
orden = str2double(get(handles.ingresarOrdenButton, 'String'));
funcion = get(handles.ingresarFuncionButton, 'String');

for s = 1:orden
p1 = 0;
p2 = 0;
n = 2 * s;
r = 0;
fx = zeros(1, n + 1);
h = (b - a) / n;
hh = a + h;
x = a;
fx(1) = eval(funcion);
for r = 2:(n + 1)
x = hh;
fx(r) = eval(funcion);
hh = hh + h;
end
for r = 2:2:n
p1 = p1 + fx(r);
end
for r = 3:2:(n - 1)
p2 = p2 + fx(r);
end
integral = ((b - a) / (3 * n)) * (fx(1) + (4 * p1) + (2 * p2) + fx(n + 1));
end
set(handles.mostrarResultadoStatic, 'String', num2str(integral));

function ingresarFuncionButton_Callback(hObject, eventdata, handles)


% hObject handle to ingresarFuncionButton (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 ingresarFuncionButton as text
% str2double(get(hObject,'String')) returns contents of
ingresarFuncionButton as a double

% --- Executes during object creation, after setting all properties.


function ingresarFuncionButton_CreateFcn(hObject, eventdata, handles)
% hObject handle to ingresarFuncionButton (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 ingresarLimiteAButton_Callback(hObject, eventdata, handles)


% hObject handle to ingresarLimiteAButton (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 ingresarLimiteAButton as text


% str2double(get(hObject,'String')) returns contents of
ingresarLimiteAButton as a double

% --- Executes during object creation, after setting all properties.


function ingresarLimiteAButton_CreateFcn(hObject, eventdata, handles)
% hObject handle to ingresarLimiteAButton (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 ingresarLimiteBButton_Callback(hObject, eventdata, handles)


% hObject handle to ingresarLimiteBButton (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 ingresarLimiteBButton as text


% str2double(get(hObject,'String')) returns contents of
ingresarLimiteBButton as a double

% --- Executes during object creation, after setting all properties.


function ingresarLimiteBButton_CreateFcn(hObject, eventdata, handles)
% hObject handle to ingresarLimiteBButton (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 ingresarOrdenButton_Callback(hObject, eventdata, handles)


% hObject handle to ingresarOrdenButton (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 ingresarOrdenButton as text


% str2double(get(hObject,'String')) returns contents of ingresarOrdenButton
as a double

% --- Executes during object creation, after setting all properties.


function ingresarOrdenButton_CreateFcn(hObject, eventdata, handles)
% hObject handle to ingresarOrdenButton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not

You might also like