Está en la página 1de 3

LAZARTE AQUINO JUAN F.

PRACTICA Nº 2 DE METODO NUMERICOS


a.par o impar
n=input('ingrese el numero: ');
if mod(n,2)==0;
fprintf('el nuemro es par\n');
else
fprintf('el numero es impar\n');
end

b.producto o suma
a=input('ingrese primer numero: ');
b=input('ingrese segundo numero: ');
if (a>0&b>0)
disp (a*b)
else
disp(a+b)
end

c. De 5 numeros el menor es:


x=[0 0 0 0 0];
x(1)=input('ingrese 1ºnumero: ');
x(2)=input('ingrese 2ºnumero: ');
x(3)=input('ingrese 3ºnumero: ');
x(4)=input('ingrese 4ºnumero: ');
x(5)=input('ingrese 5ºnumero: ');
for i = 1:4
for i = 1:4
if x(i) >= x(i+1);
a = x(i);
x(i)= x(i+1);
x(i+1) = a;
end
end
end
menor=x(1)

d.Raices de una ecuación cuadrática


a=input('ingrese a: ');
b=input('ingrese b: ');
c=input('ingrese c: ');
if a>0
R1=(-b+sqrt(b^2-4*a*c))/(2*a)
R2=(-b-sqrt(b^2-4*a*c))/(2*a)
end

e.¿se puede formar un triangulo?


x=[0 0 0];
x(1)=input('ingrese 1ºlongitud: ');
x(2)=input('ingrese 2ºlongitud: ');
x(3)=input('ingrese 3ºlongitud: ');
for i=1:2
for i=1:2
if x(i)>=x(i+1);
a=x(i);
x(i)=x(i+1);
x(i+1)=a;
end
end
end
if (x(3)-x(1))<x(2)& x(2)<(x(3)+x(1))
disp('SE PUEDE FORMAR UN TRIANGULO')
if (x(3))^2==(x(1))^2+(x(2))^2
disp('EL TRIANGULO ES RECTANGULO')
elseif (x(3))^2>(x(1))^2+(x(2))^2
disp('EL TRIANGULO ES OBTUSANGULO')
elseif (x(3))^2<(x(1))^2+(x(2))^2
disp('EL TRIANGUILO ES ACUTANGULO')
end
else disp('NO SE PUEDE FORMAR UN TRIANGULO')
end

f.Algoritmo que grafique y evalue la función.


function y=f(x)
global fun
if x<=0
y=x.^2+1;
elseif 0<x & x<3
y=x.^2+3*x+2;
elseif x>=3
y=x+1;
end

g.Lea 2 enteros y obtenga el valor nuerico.


a=input('ingrese a: ')
b=input('ingrese b: ')
if a^2-b^2<0
disp('f(x)'); 2*a+b
elseif a^2-b^2==0
disp('f(x)'); a^2-2*b
else
disp('f(x)'); a+b
end

h.Lea 3 nuemros e indique el intermedio.


x=[0 0 0]
x(1)=input('ingrese 1ºnumero: ');
x(2)=input('ingrese 2ºnumero: ');
x(3)=input('ingrese 3ºnumero: ');
for i=1:2
for i=1:2
if x(i)>=x(i+1);
a=x(i);
x(i)=x(i+1);
x(i+1)=a
end
end
end
x(2)
i.Dada la hora y minutos y segundos encduentre la hora del segundo anterior.
j.En una universidad tiene como política considerar 3 notas en cada curso la nota de
trabajos T,la nota de medio ciclo M y la nota de fin de ciclo cada una con un peso de
20% ,40%,40% respectivamente,un alunmo e scalificado según lo siguiente:
bueno: su promedio esta entre 16 y 20
regular: su promedio esta entre 11 y 15
malo: su promedio esta entre 6 y 10
a=input('ingrese nota de trabajos: ');
b=input('ingrese nota de medio ciclo: ');
c=input('ingrese nota de fin de ciclo: ');
p=(20*a+40*b+40*c)/100
if p>16 & p<20
disp('BUENO')
elseif p>11 & p<15
disp('REGULAR')
elseif p>6 & p<10
disp('MALO')
end

También podría gustarte