You are on page 1of 19

INGENIERÍA QUIMICA

INGENIERIA AMBIENTAL

III

COMPUTACION II

Walter Moreno Eustaquio

PRACTICA N°1

Lizeth Iraita Santiago


PRACTICA N°1

N°1:
clear all
clc
Pm=input('valor del peso molecular: ');
M=input('valor de la masa: ');
nm=M/Pm;
fprintf('el numero de moles: %.2f\n',nm);

N°3:
clear all
clc
D=input('valor de densidad: ');
w=input('valor % de peso: ');
pm=input('valor de pm: ');
mo=(10*D*w)/pm;
fprintf('la molaridad de esta solucion es: %.2f\n',mo);
N°5:
clear all
clc
n=input('numero de moles del componente: ');
nt=input('numero total de moles: ');
fm=n/nt;
fprintf('la fraccion molar es: %.2f\n',fm);

N°7:
clear all
clc
m=input('valor de metros: ');
pies=m*3.2;
fprintf('el valor convertido en pies es: %8.2f\n',pies);
pulgadas=m*39.37;
fprintf('el valor convertido en pulgadas es: %8.2f\n',pulgadas);
N°9:
clear all
clc
r=input('ingresar valor: ');
h=input('ingresar valor: ');
v=pi*r^2*h
fprintf('el volumen del cilindro es: %4.4f\n',v);

N°11:
clear all
clc
vi=input('ingresar velocidad inicial (m/seg): ');
t=input('ingresar tiempo(seg): ');
a=input('ingresar aceleracion (m/seg^2): ');
vf=vi+a*t;
e=vi*t+(a/2)*t^2;
fprintf('el espacio recorrido es: %8.2f\n',e);
N°13:
clear all
clc
m=input('valor de la masa (kg): ');
v=input('valor de volumen (L): ');
D=m/v;
fprintf('la densidad del cuerpo es: %.2f\n',D);

N°15:
clear all
clc
x=input('ingresar valor de x: ');
y=input('ingresar valor de y: ');
z=x;
x=y;
y=z;
fprintf('el nuevo valor de la variable x es: %.2f\n',x);
fprintf('el nuevo valor de la variable y es: %.2f\n',y)
N°17:
clear all
clc
capital=input('ingrese capital: ');
tasa=input('ingrese la tasa de interes(%): ');
np=input('numero de periodos: ');
monto=capital*(1+tasa/100)^np;
interes=monto-capital;
fprintf('el interes generado es; %8.2f\n',interes);

N°19:
clc
segundos=input('numero de segundos: ');
a=fix(segundos/3600);
segundos=rem(segundos,3600);
m=fix(segundos/60);
d=rem(segundos,60);
fprintf('tiene %d horas, %d minutos y %d segundos\n',a,m,d);
N°21:
clear all
clc
nm=input('numero con la cifra de los millares:');
nu=input('numero de cifras de las unidades :');
fprintf('el alogaritmo formado : %d f\n',nm,nu);

N°23:
clear all
clc
Horas=input('Ingrese cantidad de horas(HH) : ');
Minutos=input('Ingrese cantidad de minutos(MM) : ');
Segundos=input('Ingrese cantidad de segundos(SS) : ');
fprintf('La hora ingresada es: %d : %d : %d \n',Horas, Minutos,
Segundos);
H=fix(200/3600);
TA=rem(200,3600);
M=fix(TA/60)+Minutos;
S=rem(TA,60)+Segundos;
HH=Horas+H
MM=fix(S/60)+M;
SS=rem(S,60);
fprintf('La hora despues de 200 segundos es: %d: %d : %d \n',HH, MM,
SS);
Practica: Nº 2
Ejercicio: Nº 2
clear all
clc
x=input('Ingrese 1° evaluacion: ');
y=input('Ingrese 2° evaluacion: ');
p=(x+y)/2;
if p>=10.5
x==18 | y==15
disp('APROBADO');
else x<10.5
x==03 | y==08
disp('DESAPROBADO');
end

COMMAND WINDOW
ingrese el valor de n1: 10.5
ingrese el valor de n2: 14

p=

12.2500

Aprobado

Ejercicio: Nº 4
clear all
clc
a=input('primer número:');
b=input('segundo numero:');
c=input('tercer numero:');
int=a;
if b>int
int=b;
end
if c>int
int=c;
end
fprintf('el numero intermedio es:%2.3f\n',int);

COMMAND WINDOW
primer número:24
segundo numero:3
tercer numero:56
el numero intermedio es:56.000

Ejercicio: Nº 6
clearall
clc
x=input('nota del primer examen: ');
y=input('nota del segundo examen: ');
z=input('nota del tercer examen: ');
if x>10 ||y>10 ||z>10
disp('recibe 160')
elseif x<11 || y<11 || z<11
disp('recibe 100')
elseif x<11 || y>10 || z>10
disp('recibe 140')
elseif x<11 || y<11 || z>10
disp('recibe 120')
elseif x>11 || y<11 || z<11
disp('recibe 120')
else
disp('recibe 140')
end

COMMAND WINDOW
nota del primer examen: 12
nota del segundo examen: 11
nota del tercer examen: 15
recibe 160

Ejercicio: Nº 8
clear all
clc
x=input('ingresar el valor del angulo: ');
y=input('ingresar el valor del angulo: ');
z=input('ingresar el valor del angulo: ');
s=x+y+z;
if s==180
if x==60 || y==60 || z==60
disp('Es un triangulo equilatero');
elseif x>60 || y>60 || z>60
dis('Es un triangulo escaleno');
else
disp('Es un triangulo isoseles');
end
else
disp('no pertenece a ningun triangulo');
end

COMMAND WINDOW
números enteros:8424
es par

Ejercicio: Nº 10
clear all
clc
n=input('números enteros:');
if rem(n,4)==0
disp('es par');
else
disp('es impar');
end

COMMAND WINDOW
ingresar el valor del ángulo: 60
ingresar el valor del ángulo: 60
ingresar el valor del ángulo: 60
Es un triángulo isósceles

Ejercicio: Nº 12

clear all
clc
num=input('ingrese notas: ');
a=input('primera nota: ');
b=input('segunda nota: ');
c=input('tercera nota: ');
d=input('cuarta nota: ');
exr=a;
if b>exr
exr=b;
end
if c>exr
exr=c;
end
if d>exr
exr=d
end
fprintf('El promedio final es: %7.2f\n',num);

COMMAND WINDOW
ingrese notas: 13
primera nota: 17
segunda nota: 19
tercera nota: 15
cuarta nota: 11
El promedio final es: 13.00

Ejercicio: Nº 14
clear all
clc
b=input('base(promedio ponderado): ');
if b>=17
disp('categoria A');
elseif b>=14 || b<17
disp('categoria B');
elseif b>=12 || b<14
disp('categoria C');
elseif b<12
disp('categoria D');
end

COMMAND WINDOW
base(promedio ponderado): 15
categoría B

Ejercicio: Nº 16

COMMAND WINDOW

Practica: Nº 3
Ejercicio: Nº 1

clear all
clc
color=input('Ingrese color de la Bolita entre apostrofos: ');
importe=input('Ingrese monto de dinero a pagar :');
switch color
case {'azul','Azul'}
azul=importe*0.20;
fprintf('El valor con descuento es: %5.2f\n',azul);
case {'roja','Roja'}
roja=importe*0.30;
fprintf('El valor con descuento es: %5.2f\n',roja);
case {'blanca','Blanca'}
blanca=importe;
fprintf('No hay descuento y el monto a pagar es:
%5.2f\n',blanca);
otherwise
disp('El color o importe es incorrecto');
end

COMMAND WINDOW
Ingrese color de la Bolita entre apostrofos: 'roja'
Ingrese monto de dinero a pagar :150
El valor con descuento es: 45.00

Ejercicio: Nº 3
clear all
clc
clase=input('ingresar entre A y D: ','s');
switch clase
case {'25','A'}
disp('EL SUELDO ES DE 25 SOLES Y ES DE CLASE A');
case {'20','B'}
disp('EL SUELDO ES DE 20 SOLES Y ES DE CLASE B');
case {'15','C'}
disp('EL SUELDO ES DE 15 SOLES Y ES DE CLASE C');
case {'10','D'}
disp('EL SUELDO ES DE 10 SOLES Y ES DE CLASE D');
end

COMMAND WINDOW
ingresar entre A y D: C
EL SUELDO ES DE 15 SOLES Y ES DE CLASE C

Ejercicio: Nº 5
clear all
clc
d=input('Ingrese numero de dia del 1 al 30: ');
m=input('Ingrese numero de mes del 1 al 12: ');
if m==1
if d<21;
disp('Capricornio');
else
disp('Acuario');
end
end
if m==2
if d<19
disp('Acuario');
else
('Piscis');
end
end
if m==3
if d<21
disp('Piscis');
else
disp('Aries');
end
end
if m==4
if d<21
disp('Aries');
else
disp('Tauro');
end
end
if m==5
if d<22
disp('Tauro');
else
disp('Geminis');
end
end
if m==6
if d<21
disp('Geminis');
else
disp('Cancer');
end
end
if m==7
if d<21
disp('Cancer');
else
disp('Leo');
end
end
if m==8
if d<21
disp('leo');
else
disp('Virgo');
end
end
if m==9
if d<22
disp('Virgo');
else
disp('libra');
end
end
if m==10
if d<21
disp('Libra');
else
disp('Escorpio');
end
end
if m==11
if d<21
disp('Escorpio');
else
disp('Sagitario');
end
end
if m==12
if d<21
disp('Capricornio');
else
disp('Capricornio');
end
end

COMMAND WINDOW
Ingrese número de día del 1 al 30: 18
Ingrese número de mes del 1 al 12: 7
Cáncer

Ejercicio: Nº 7
clear all
clc
n1=input('Ingrese primer numero: ');
n2=input('Ingrese segundo numero: ');
operador=input('Que operacion desea realizar (ingresar datos entre
apostrofos): ');
switch operador
case {'+'}
s=n1+n2;
fprintf('El nuevo valor de suma es: %.0f\n',s);
case {'-'}
r=n1-n2;
fprintf('El nuevo valor de resta es: %.0f\n',r);
case {'multiplicacion'}
m=n1*n2;
fprintf('El nuevo valor de multiplicacion es: %.0f\n',m);
case {'/'}
d=n1/n2;
fprintf('El nuevo valor de divsion es: %.0f\n',d);
case {'^'}
p=n1^n2;
fprintf('El nuevo valor de potencia es: %.0f\n',p);
end

COMMAND WINDOW
Ingrese primer número: 45
Ingrese segundo número: 7
Que operación desea realizar (ingresar datos entre apóstrofos): '/'
El nuevo valor de división es: 6

Ejercicio: Nº 9
Ejercicio: Nº 11
Practica: Nº 4
Ejercicio: Nº 2
clear all
clc
n=input('cantidad de numeros: ');
sp=0;
for i=1:n
x=input('Ingrese numero: ');
if rem(x,2)==0
sp=sp+x;
end
end
fprintf('La suma de pares es: %d\n',sp);

COMMAND WINDOW
cantidad de números: 4
Ingrese número: 5
Ingrese número: 6
Ingrese número: 7
Ingrese número: 4
La suma de pares es: 10

Ejercicio: Nº 4
clear all
clc
x=input('Ingresar el valor de X: ');
n=input('Ingresar el valor de N: ');
p=1;
for i=1:n
p=p*x;
end
fprintf('La potencia %d elevado a %d es: %d\n',x,n,p);

COMMAND WINDOW
Ingresar el valor de X: 4
Ingresar el valor de N: 2
La potencia 4 elevado a 2 es: 16
Ejercicio: Nº 6
clear all
clc
x=input('Ingresar el valor de X: ');
n=input('Ingresar el valor de N: ');
s=1;
f=1;
for i=1:n
f=f*i;
s=s-x^i/f;
end
fprintf('la sumatoria es: %2d\n',s);
COMMAND WINDOW
Ingresar el valor de X: 8
Ingresar el valor de N: 6
la sumatoria es: -9.321556e+02

Ejercicio: Nº 8
clear all
clc
n=input('Ingrese numero: ');
f=1;
s=0;
for i=1:n
f=f*2;
if rem(i,2)==0
s=s+i
end
end
fprintf('el numero es: %.2f\n',f);
fprintf('el suma es: %.2f\n',s);

COMMAND WINDOW
Ingrese numero: 8

s=

s=

s=

12

s=

20

el numero es: 256.00


el suma es: 20.00

Ejercicio: Nº 10
clear all
clc
n=input('Ingrese la cantidad de horas: ');
may=-1e30;
men=1e30;
for i=1:n
x=input('MEDIDA DE TEMPERATURA: ');
if x>may
may=x;
end
if x<men
men=x;
end
end
fprintf('La temperatura mayor es: %.2f\n',may);
fprintf('La temperatura menor es: %.2f\n',men);

COMMAND WINDOW
Ingrese la cantidad de horas: 6
MEDIDA DE TEMPERATURA: 89
MEDIDA DE TEMPERATURA: 20
MEDIDA DE TEMPERATURA: 45
MEDIDA DE TEMPERATURA: 13
MEDIDA DE TEMPERATURA: 60
MEDIDA DE TEMPERATURA: 75
La temperatura mayor es: 89.00
La temperatura menor es: 13.00

Ejercicio: Nº 12
clear all
clc
n=input('Ingrese cantidad de notas: ');
may=-1e30;
men=1e30;
for i=1:n
x=input('ingrese nota: ');
if x>may
may=x;
end
if x<men
men=x;
end
end
if 'p'>0
p=(may+men)/2;
fprintf('El promedio es: %.2f\n',p);
end
fprintf('La nota mayor es: %.2f\n',may);
fprintf('La nota menor es: %.2f\n',men);

COMMAND WINDOW
Ingrese cantidad de notas: 4
ingrese nota: 15
ingrese nota: 10
ingrese nota: 00
ingrese nota: 20
El promedio es: 10.00
La nota mayor es: 20.00
La nota menor es: 0.00

Ejercicio: Nº 14
clear all
clc
x=300:43:1000
s=0;
may=-1e30;
men=1e30;
for i=300:43:1000
s=s+i;
if i>may
may=i;
end
if i<men
men=i;
end
end
fprintf('la suma es: %d\n',s);
fprintf('el mayor es: %d\n',may);
fprintf('el menor es: %d\n',men);

COMMAND WINDOW

x=

Columns 1 through 10

300 343 386 429 472 515 558 601 644 687

Columns 11 through 17

730 773 816 859 902 945 988

la suma es: 10948


el mayor es: 988
el menor es: 300
Ejercicio: Nº 16
clear all
clc
x=input('Ingresar el valor de A: ');
n=input('Ingresar el valor de B: ');
Y=input('Ingresar el valor de N: ');
s=1;
f=1;
for i=1:n
f=f*i;
s=s-x^i/f;
end
fprintf('la sumatoria es: %2d\n',s);

COMMAND WINDOW
Ingresar el valor de A: 20
Ingresar el valor de B: 15
Ingresar el valor de N: 10
la sumatoria es: -7.593472e+07

You might also like