555Examnes
-
Upload
jose-alfredo-choque-paredes -
Category
Documents
-
view
213 -
download
1
description
Transcript of 555Examnes
EJERCICIOS DE LA PAGINA 20-24
PROBLEMA 9
x=pi/4; y=exp(1); z=2.31;
w=(((log(x))^2+sqrt(1+y^3))/(1-sin(x)))+(y*z)
w = 22.1562
PROBLEMA 12
x=pi/6;
y=exp(1);
z=4/7;
w= ((y^3/(y+z^2))-log(y)^2)^(2/3)/(x*sin(x)+(sqrt(1+z))/(z+y))
w = 4.9035
PROBLEMA 19
>> x=[2.24 3.56 -4.67];
y=[sqrt(2) exp(1) pi];
z=[30 45 60]*pi/180;
w=(2-z.*sin(z))./(log(y.^2+x).^2)
w =
0.8330 0.2522 0.4022
PROBLEMA 25
x=-2:0.001:2;
y=sqrt(4-x.^2)./(x.^2+1);
plot(x,y)
grid on
axis ([-3,3,-0.5,2.5])
PROBLEMA 27
x=-sqrt(2):0.001:sqrt(2);
y=(sqrt(2)-x.^2)./(x-3);
plot (x,y)
grid on
EJERCICIOS DE LA PAGINA 43-53
PROBLEMA N°01
function y=func(x) if x<-1 y=abs(x+2); elseif -1<=x & x<=3 y=sqrt(x+1)+1; else y=6-(x^2/3); endend
PROBLEMA 4
PROBLEMA 5
PROBLEMA 6Hacer el seguimiento dada la function,function r=asum(s)t=length(s);r=0;for i=1:t r=10*r+s(i)-'0'end
asum(‘4731’)
t r i4 0 04 4 14 47 24 473 34 4731 4
12. Escribir una funcion que devuelve el maximo valor n para el cual la suma S, no sea mayor o igual a un valor tope dado:
S=1+1/2+1/3+1/4+...+1/n
function n = maxdiv(x)
%12
s=0;
i=0;
while(s<=x)
i=i+1;
s=s+1/i;
end
n=i-1;
disp(n);
end
------------------------
>> maxdiv(1)
1
ans =
1
>> maxdiv(2.1)
4
ans =
4
>> maxdiv(1.6)
2
ans =
2
>> maxdiv(1.6)
3
ans =
3
=============================
13. Escribir una funcion que tome dos arreglos del mismo tamaño sume el promer elemento de A con el ultimo de B, el segundo con el penultimo de B, y asi sucesivamente.
function C = sumainv(A,B)
%13
n=length(A);
m=length(B);
if(n~=m)
disp('Los vectores tienen que ser del mismo tamaño')
else
for i=1:n
C(i)=A(i)+B(n-i+1);
end
end
end
----------------------------------------------------
>> x=[1 2 3]
x =
1 2 3
>> y=[3 2 1]
y =
3 2 1
>> sumainv(x,y)
ans =
2 4 6
===================================================
14.
PROGRAMA sumatoria
s=0;
for i=1:9999
s=s+(3/2^i)-(2/3^i);
end
disp(s)
>> sumatoria
2.0000
la sumatoria converge a 2.
17.
function c = CtaDig(n)
c=0;
while(n)
c=c+1;
x(c)=rem(n,10); %almacena el ultimo digito en un arreglo
n=floor(n/10); %elimina el ultimo digito
end
x=x(length(x):-1:1); %invierte el arreglo
disp(x);
end
-----------------------------------------------------------
>> CtaDig(416)
4 1 6
ans =
3
>> CtaDig(3)
3
ans =
1
>> CtaDig(5645)
5 6 4 5
ans =
4
============================================
20.
n=1;
i=0;
s=0;
while(n)
n=input('Ingresar un numero positivo ');
if(n==0)
disp(s/i);
return
end
i=i+1;
s=s+n;
end
-------------------------------------
>> SumaPositivos
Ingresar un numero positivo 1
Ingresar un numero positivo 2
Ingresar un numero positivo 0
1.5000
>> SumaPositivos
Ingresar un numero positivo 1
Ingresar un numero positivo 2
Ingresar un numero positivo 3
Ingresar un numero positivo 0
2
====================================
24.
function [Y] = Primo(x)
c=0;
k=1;
Y=0;
for i=1:x
for j=1:i
if(~rem(i,j))
c=c+1;
end
end
if(c==2)
Y(k)=i;
k=k+1;
end
c=0;
end
end
>> Primo(10)
ans =
2 3 5 7
>> Primo(102)
ans =
Columns 1 through 15
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47
Columns 16 through 26
53 59 61 67 71 73 79 83 89 97 101
=====================================================================
28.
function y = MaxMin(x)
a=input('Ingresar valor maximo: ');
b=input('Ingresar valor minimo: ');
n=length(x);
s=0;
d=0;
for i=1:n;
if(x(i)>=b&&x(i)<=a)
s=s+x(i);
d=d+1;
end
end
y=s/d;
end
-------------------------------------------
>> x=[4 5 7 9 3 11 12 15 7 24 13]
x =
4 5 7 9 3 11 12 15 7 24 13
>> MaxMin(x)
Ingresar valor maximo: 15
Ingresar valor minimo: 7
ans =
10.5714
==========================================
32.
function y = encuentra_posicion(x,num)
n=length(x);
y=0;
for i=1:n
if(x(i)==num&&~y)
y=i;
n=i-1;
end
end
if(~y)
disp('Numero no encontrado');
end
end
-------------------------------------------------
x =
14 3 5 2 4 8 15 4
>> encuentra_posicion(x,15)
ans =
5
==================================================
33.
function [y] = mediana(x)
n=length(x);
if(~rem(n,2))
y=(x((n/2))+x((n/2)+1))/2;
else
y=x(ceil(n/2));
end
end
-----------------------------------------------
>> x=[5 6 4 2 3]
x =
5 6 4 2 3
>> mediana(x)
ans =
4
>> x=[5 6 4 2 3 5]
x =
5 6 4 2 3 5
>> mediana(x)
ans =
3
==============================================
34.
function [s] = exponencial(x,n)
%34. s=exponencial(x,n)
%
s=0;
d=1;
for i=1:n
s=s+(x^i)/d;
d=d*(i+1);
end
s=s+1;
end
------------------------------
>> exponencial(2,3)
ans =
6.3333
>> exponencial(2,4)
ans =
7