Beruflich Dokumente
Kultur Dokumente
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
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- 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)