Está en la página 1de 3

Laboratorio12

Programa 1
Funcin Factorial
function [s] = fact( n )
s=1;
for p=1:1:n
s=s*p;
end

end

Funcin Sumatoria
function [x] = Sum( q )
x=0;
for i=1:1:q
z=mod(i,2);
if z>0
x=x+((i^2)/fact(i));
else
end
end
end

Programa 2
clc;
%
n=input('Dame el numero de terminos: ');
x=input('Dame x: ');
ser2(n,x)

function s=ser2(n,x)
s=0;
for i=1:n
a=fact(i);
s=s+ (a/(x*(sqrt(2^i))));
end
end
Programa 3
clc;
%
n=input('Dame el numero de terminos: ');
a=input('Dame a: ');
b=input('Dame b: ');
ser4(n,a,b)

function s=ser4(n,a,b)
s=0;
for i=1:n
o=fact(i);
y=rem(i,2);
if y~=0
s=s+((a^i)/o);
else
s=s-((b^i)/o);
end
end
end

Programa 4

clc;
%
n=input('Dame el numero de terminos: ');
x=input('Dame x: ');
ser3(n,x)
function s=ser3(n,x)
s=0;
for i=1:n
a=fact(i);
y=rem(i,2);
if y~=0
s=s+ ((x^i)/((2^i)*a));
else
s=s- ((x^i)/((2^i)*a));
end
end
end

También podría gustarte