Codigo de Matlab 2017 Salazar Reyes Alejandro Esteban
%ejercicio 1.4, realizado por Salazar Reyes Alejandro Esteban 16210726
clear all
close all
(2*sqrt(2)*1103/9801)^-1
((2*sqrt(2)/9801)*(1103+factorial(4)*(1103+26390)/(396^4)))^-1
%ejercicio 1.5, realizado por Salazar Reyes Alejandro Esteban 16210726
clear all
close all
x = 2;
x1 = -1:0.1:1
y = (exp(x)-exp(-x))/2;
y2 = sinh(x);
Codigo de Matlab 2017 Salazar Reyes Alejandro Esteban
%ejercicio 2.4, realizado por Salazar Reyes Alejandro Esteban 16210726
clear all
close all
y=10, x=3;
u = x + y
v = x.* y
w = x/y
z = sin(x)
r = 8.*sin(x)
s = 5.*sin(x.*y)
p = (x)*y
%ejercicio 2.5, realizado por Salazar Reyes Alejandro Esteban 16210726
x=[1 4 3 2 9 4];
y=[2 3 4 1 2 3];
Codigo de Matlab 2017 Salazar Reyes Alejandro Esteban
u=x+y
w=x/y
z=sin(x)
r=8*sin(x)
s=5.*sin(x.*y)
p=(x).^y
%ejercicio 3.5, realizado por Salazar Reyes Alejandro Esteban 16210726
clc
clear all
close all
r1=1;
h1=5;
r2=2;
h2=3;
V1 = pi*r1^2*h1
S1 = 2*pi*r1^2+2*pi*r1*h1
V2 = pi*r2^2*h2
S2 = 2*pi*r2^2+2*pi*r2*h2
Codigo de Matlab 2017 Salazar Reyes Alejandro Esteban
%ejercicio 4.8, realizado por Salazar Reyes Alejandro Esteban 16210726
clear all
close all
function [nRoots,r] = myNRoots(a,b,c);
r1 = (-b+sqrt((b*2)-4.*a.*c))/(2.*a);
r2 = (-b-sqrt((b*2)-4.*a.*c))/(2.*a);
r=[r1 r2];
if (b.^2)>4.*a.*c
nRoots=2;
elseif (b*2)>4.*a.*c
nRoots=-2;
else
nRoots=-1;
end
end
%ejercicio 6.6, realizado por Salazar Reyes Alejandro Esteban 16210726
clear all
close all
format long
function gR = myGoldenRatio (DA);
%N=0;
F(1:2) = 1;
%DA = input('How many decimals of accuracy would you like to calculate
the Golden Ratio to: ');
G = ((1+sqrt(5))/2);
GR = 1;
index = 3;
while abs(G-GR) > 10^-DA
F(index) = F(index-1)+F(index-2);
GR = F(index)/F(index-1);
index = index + 1;
end
gR=GR;
disp('Golden Ratio = ');
disp((1+sqrt(5))/2);
end
function [row] = myPascalRow(m)
row(1,1)=1;
row(2,1:2)= (1 1 );
if m<3
return
end
for r=3:m
row(r,1)=1;
for c=2:r-1
row(r,c)=row(r-1,c-1)+row(r-1,c);
Codigo de Matlab 2017 Salazar Reyes Alejandro Esteban
end
row(r,r)=1;
end
end
%ejercicio 8.6, realizado por Salazar Reyes Alejandro Esteban 16210726
printf("\n");
function [d]=myIEEE2Dec(IEEE);
longitud = length (IEEE);
s = IEEE(1);
ex= IEEE(2:9);
m =IEEE(10:32);
exponent = bin2dec(ex);
if longitud == 32;
else
printf("error, el valor deber conter 32 bits.");
endif
if s==1
printf("-");
s = 1;
elseif s==0
printf("+");
s=0;
endif
i=0;
for n=1:23
i= str2num(m(n))/2^n+i;
endfor
d= (-1)^s*2^(exponent-127)*(1+i);
endfunction
[d]=myIEEE2Dec(['11000010010000000000000000000000'])
[d]=myIEEE2Dec(['11000101000001010000100010111000'])