0% found this document useful (0 votes)
63 views3 pages

El Toño No Tiene Q Ver

The document contains MATLAB code for several functions: 1) A function to determine if a number is even, odd, or not an integer. 2) A function to determine if a number is prime. 3) A function that prints the Fibonacci sequence up to a given number. 4) A function that uses the Newton-Raphson method to find the roots of a polynomial. 5) Code for a graphical user interface (GUI) with a button that runs the Newton-Raphson function when pressed.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views3 pages

El Toño No Tiene Q Ver

The document contains MATLAB code for several functions: 1) A function to determine if a number is even, odd, or not an integer. 2) A function to determine if a number is prime. 3) A function that prints the Fibonacci sequence up to a given number. 4) A function that uses the Newton-Raphson method to find the roots of a polynomial. 5) Code for a graphical user interface (GUI) with a button that runs the Newton-Raphson function when pressed.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Pares e impares

function esentero(r)
if r==floor(r)
disp('es entero')
if mod(r,2)==0
disp('Es Par')
else
disp('Es Impar')
end
else
disp('no es entero')
end

primos
function esprimo(r)
c=0;
if r==floor(r)
for i=1:r
if mod(r,i)==0
c=c+1;
end
end
if c==2
disp('Es Primo')
else
disp('No Es Primo')
end

fibonasi
clc;
a=0;
b=1;
c=0;
fprintf('Serie Fibonacci: %d \t %d',a,b)
while c<=r
c=a+b;
a=b;
b=c;
if c<=r
fprintf('\t %d',c)
end
end
fprintf('\n')

newton
function newtonr()
%Programa para hallar las raices de un polinomio por el metodo de
Newton
%Raphson, Datos iniciales el polinomio, x0, tolerancia.
clc;
syms x;
f=input('Ingrese la funcion: ');
x0=input('Ingrese el valor inicial: ');
t=input('Ingrese la Tolerancia: ');
e=1;
f;
d=diff(f);
r=x0-(subs(f,x,x0))/(subs(d,x,x0));
while abs(e)>t
x0=r;
r=x0-(subs(f,x,x0))/(subs(d,x,x0));
e=x0-r;
end
r
end

interfas usuario

function varargout = boton(varargin)


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

% Last Modified by GUIDE v2.5 26-Oct-2018 14:55:41

% Begin initialization code - DO NOT EDIT


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


function boton_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 boton (see VARARGIN)

% Choose default command line output for boton


handles.output = hObject;

% Update handles structure


guidata(hObject, handles);

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


% uiwait(handles.figure1);

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


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)
newtonr

You might also like