Documentos de Académico
Documentos de Profesional
Documentos de Cultura
MARIA
GRUPO :
AREQUIPA 2014
PRIMERA PRCTICA
9.
x=pi/4
y=exp(1)
z=2.31
w=((log(x)^2+sqrt(1+y^3))/1-sin(x))+((y)*(z))
12.
x=30
y=exp(1)
z=4/7
w=((y^3)/(y+z^2))-((log(y)^2)^2/3)/sin(x)+(sqrt(1+z)/(z+y))
19.
x=input('x=')
y=input('y=')
z=input('z=');
w= (2-sin(z))/(log(y^2+x)^2)
X Y Z W
2.24 2 30 0.5434
3.56 e 45 0.2619
-4.56 60 0.4172
25.
%el dominio de F:-2<x=<=2%
x=(-2:0.01:2)
w= sqrt(4-x.^2)/(x.^2+1)
plot(x,w),grid
27.
%el dominio de F:-1<=x<=1%
x=(-1:0.01:1)
w=(sqrt(2-x^2))/(x-3)
plot(x,w),grid
35.
x=linspace(-5,2,100);
y=3+x.*exp(-x);
x0=linspace(2,5,500);
y0=2;
plot(x,y,'r',x0,y0,'b')
axis([-5 5 -5 5])
37.
function y=grafico3(z)
x=[-z:0.02:z];
f=(x.^2)/sqrt(1-x.^2);
g=x.*(x.^2)+1;
plot(f,x,'r-',g,x,'b-'),grid
end
SEGUNDA PRCTICA
1. Si:
| + 2| < 1
+1+1 1 3
() =
2
{ 6 3 >3
Escribir la funcin y los comandos en matlab que sirvan para
calcular la siguiente expresin, mostrando el resultado con 8
decimales
(2 + 3) + (3 )
=
( + 3) ( )
function y=funcion(x)
e=exp(1);
if x<-1
x=((-2*pi+3+2)+(e*(pi/3)+2))/((pi+3+2)*(pi-e)+2)
end
if -1<=x<=3
x=((sqrt(2*pi+3+1)+1)+(e*sqrt((pi/3)+1)+1))/((sqrt(pi+3+1)+1)
*sqrt(pi-e+1)+1)
end
if x>3
x=((6-
(2*pi+3)^2/2)+(e*((6+(pi/3)+2)/3)^2))/((6+((pi+3)^2)/3)*(6+(p
i-e)^2/3))
end
end
function s=sas()
f=input('f= ')
while ~rem(f,2)
s=s+f;
f=input('f= ')
end
end
Qu retorna si se ingresan los valores 4 8 10 1 3 5?
function y=prob2(a,b)
while rem(a,b)~=0
t = a;
a = b;
b = rem(a, b);
end
y=b
Qu valor retorna?
n=length(A);
m=length(B);
if(n~=m)
else
for i=1:n
C(i)=A(i)+B(n-i+1);
end
end
end
>> x=[2 4 6]
x =
2 4 6
>> y=[6 4 2]
y =
6 4 2
>> suminv(x,y)
ans =
4 8 12
>> sumatoria
2.0000
La sumatoria converge a 2.
17. Escribir una funcin CtaDig(num), que reciba un nmero
entero positivo y retorne cuantos dgitos tiene, as
CtaDig(416) debe retornar 3, pues el numero 416 tiene 3
dgitos que son 4, 1, 6.
function c = CtaDig(num)
c=0;
while(n)
c=c+1;
x(c)=rem(n,10); %almacena el ultimo digito en un arreglo%
num =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(11)
1 1
ans =
2
18. Escribir un programa que reciba nmeros enteros positivos
por teclado y determine cuantos son mayores que 10. El nmero
cero ser el indicador del fin de ingreso.
function q = enteros_positivos()
i=1; n=0;
while data ~= 0
if mod(u,1)==0 & u>0
x(i)=u;
i=i+1;
end
if u>=10
n=n+1;
end
u=input('Ingrese numero terminar con 0 :');
end
y=x
q=n;
end
20. Escribir una funcin en Matlab que solicite por teclado el
ingreso de nmeros positivos hasta ingresar el nmero cero,
luego retorne el promedio de los nmeros ingresados (sin
considerar el cero ingresado al final); as, si se ingresa
sucesivamente los nmeros 1, 2, 3, 4, 5, 0 deber retornar su
promedio que es: (1+2+3+4+5/5) que es igual a 3.
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 3
Ingresar un numero positivo 4
Ingresar un numero positivo 5
Ingresar un numero positivo 6
Ingresar un numero positivo 0
3.5000
2 3 5 7 11
>>x=[4 5 4 7 9 3 11 12 15 7 24 13];
El min = 7 y el max = 15. La funcion aplicada a este vector,
con estos topes pasados con estos parmetros, max, min,
deber devikver 10.57143 que es igual a
7+9+11+12+15+7+13/7=10.57142857142857
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
>> MaxMin(x)
Ingresar valor maximo: 15
Ingresar valor minimo: 7
ans =
10.5714
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
function y =fuerza(k,c)
r=(300^2+c^2)^(1/2);
x=r-300;
y=k*x*c/r;
end
c1=0:1:600;
k1=2;
for i=1:601
y1(i)=fuerza(k1,c1(i));
end
k2=4;
for i=1:601
y2(i)=fuerza(k2,c1(i));
end
subplot(1,2,1)
plot(c1,y1)
title('Grafico 1')
xlabel('C en mm')
ylabel('F en N')
subplot(1,2,2)
plot(c1,y2)
title('Grafico 2')
xlabel('C en mm')
ylabel('F en N')