Académique Documents
Professionnel Documents
Culture Documents
PROGRAMAS
ALUMNA: Solis Santiago, Jasmin Yanina
ESCUELA: INGENIERIA QUIMICA
CURSO: METODOS NUMERICOS
1.
clc
disp('====PROGRAMA PARA HALLAR LA DIVISION=======')
disp('====AUTOR: SOLIS SANTIAGO JASMIN YANINA====')
disp('===========================================')
n=input('ingrese el valor de n: ');
clc
disp('==========================================')
fprintf('TABLA DE LA DIVISION DEL:%d\n',n)
disp('==========================================')
x=0;
if n<=12
while x<12
x=x+1;
s=x*n;
fprintf('\n%d÷%d=%d \n',s,n,x)
end
else
disp('el numero ingresado esta fuera del rango')
end
disp('==========================================')
==========================================
TABLA DE LA DIVISION DEL:12
==========================================
12÷12=1
24÷12=2
36÷12=3
48÷12=4
60÷12=5
72÷12=6
84÷12=7
96÷12=8
108÷12=9
120÷12=10
132÷12=11
144÷12=12
==========================================
METODOS NUMERICOS
UNIVERSIDAD NACIONAL DEL CENTRO DEL PERÚ INGENIERÍA QUIMICA
2.
clc
disp('**************************************************************')
disp('------------PROGRAMA DE MOVIMIENTO DE DOS COCHES--------------')
disp('**************************************************************')
format short
v0tren=54*5280/3600;
v0coche=28*5280/3600;
acoche=4;
t=0:10;
y=-400+v0tren*t;
x=-200+v0coche*t+0.5*acoche*t.^2;
d=sqrt(x.^2+y.^2);
v0coche=v0coche+acoche*t;
velocidad_trenRcoche=sqrt(v0coche.^2+v0tren.^2);
disp('===============================================================')
disp(' T POStren POScoche Distancia Vcoche Vtren')
disp('===============================================================')
disp([t' y' x' d' v0coche' velocidad_trenRcoche' ])
disp('===============================================================')
CORRIENDO PROGRAMA
**************************************************************
------------PROGRAMA DE MOVIMIENTO DE DOS COCHES--------------
**************************************************************
===============================================================
T POStren POScoche Distancia Vcoche Vtren
===============================================================
0 -400.0000 -200.0000 447.2136 41.0667 89.2139
1.0000 -320.8000 -156.9333 357.1284 45.0667 91.1243
2.0000 -241.6000 -109.8667 265.4077 49.0667 93.1675
3.0000 -162.4000 -58.8000 172.7171 53.0667 95.3347
4.0000 -83.2000 -3.7333 83.2837 57.0667 97.6178
5.0000 -4.0000 55.3333 55.4777 61.0667 100.0089
6.0000 75.2000 118.4000 140.2626 65.0667 102.5003
7.0000 154.4000 185.4667 241.3239 69.0667 105.0849
8.0000 233.6000 256.5333 346.9558 73.0667 107.7561
9.0000 312.8000 331.6000 455.8535 77.0667 110.5075
10.0000 392.0000 410.6667 567.7245 81.0667 113.3333
===============================================================
METODOS NUMERICOS
UNIVERSIDAD NACIONAL DEL CENTRO DEL PERÚ INGENIERÍA QUIMICA
3.
% EQUIVALENTE DEL SISTEMA DE FUERZAS
clc
F1M=400;
F2M=500;
F3M=700;
Th1=-20;
Th2=30;
Th3=143;
F1=F1M*[cosd(Th1) sind(Th1)];
F2=F2M*[cosd(Th2) sind(Th2)];
F3=F3M*[cosd(Th3) sind(Th3)];
Ftot=F1+F2+F3;
FtotM=sqrt(Ftot(1)^2+Ftot(2)^2);
Th=atand(Ftot(2)/Ftot(1));
disp('el valor de F1 es:')
disp(F1)
disp('el valor de F2 es:')
disp(F2)
disp('el valor de F3 es:')
disp(F3)
disp('el valor de Ftot es:')
disp(Ftot)
disp('el valor de FtotM es:')
disp(FtotM)
disp('el valor de Th es:')
disp(Th)
CORRIENDO PROGRAMA
el valor de F1 es:
375.8770 -136.8081
el valor de F2 es:
433.0127 250.0000
el valor de F3 es:
-559.0449 421.2705
el valor de Th es:
64.9453
METODOS NUMERICOS
UNIVERSIDAD NACIONAL DEL CENTRO DEL PERÚ INGENIERÍA QUIMICA
4.
clc
disp('=================================================')
disp('PROGRAMA PARA HALLAR LAS DERIVADAS 1º,2º,3º ORDEN')
disp('=================================================')
syms x
s=input('ingrese la ecuacion: ');
sd=diff(s);
sf=diff(sd);
disp('----------------------')
disp('LA PRIMERA DERIVADA ES')
disp('----------------------')
disp(sd)
disp('-----------------------')
disp('LA SEGUNDA DERIVADA ES ')
disp('-----------------------')
disp(sf)
CORRIENDO PROGRAMA
=================================================
PROGRAMA PARA HALLAR LAS DERIVADAS 1º, 2º, 3º ORDEN
=================================================
ingrese la ecuación: 5*x^3+3*x^2+6*x
----------------------
LA PRIMERA DERIVADA ES
----------------------
15*x^2 + 6*x + 6
-----------------------
LA SEGUNDA DERIVADA ES
-----------------------
30*x + 6
5.
clc
x=input('introdusca un numero: ');
n=1;
an=1;
s=an;
while abs(an)>=0.0001 && n<=30
an=x^n/factorial(n);
s=s+an;
n=n+1;
end
if n>=30
disp('se necesitan mas de 30 terminos')
else
fprintf('exp(%f)=%f',x,s)
fprintf('\nEl numero de terminos usados es: %i',n)
end
CORRIENDO PROGRAMA
introdusca un numero: 6
exp(6.000000)=403.428783
El numero de terminos usados es: 24>>
METODOS NUMERICOS
UNIVERSIDAD NACIONAL DEL CENTRO DEL PERÚ INGENIERÍA QUIMICA
6.
clc
p=input('ingrese las presiones: ');
x=1:20;
coef=polyfit(x,p,3);
a=coef(1);
b=coef(2);
c=coef(3);
d=coef(4);
p3=a*x.^3+b*x.^2+c*x+d;
disp('los coeficientes de la ecuacion son')
disp(coef)
plot(x,p3,x,p,'or')
title('PRESION VS TEMPERATURA')
xlabel('TEMPERATURA')
ylabel('PRESION')
text(10,80,'p3=-0.0056*x.^3+0.6466*x.^2+3.9870*x+10.2167')
grid on
hold on
CORRIENDO PROGRAMA
ingrese las presiones: [10 20 30 40 50 60 70 80 90 100 120 140 160 180 200 220 240 260 280 300]
los coeficientes de la ecuacion son
-0.0056 0.6466 3.9870 10.2167
7.
clc
n=input('ingtrese el numero de notas: ');
format short
while n<1;
disp('no se puede sacar promedio')
n=input('ingtrese el numero de notas: ');
end
sum=0;
c=0;
nota=1;
while nota>-1 && nota<=20
while c<n
nota=input('ingtrese notas: ');
sum=sum+nota;
c=c+1;
end
nota=100;
end
p=sum/c;
while p<10.5
fprintf('el promedio de la alumna JASMIN SOLIS con %d notas es %d
puntos,DESAPROBADO ',n,p)
end
if p>10.5 && p<15
fprintf('el promedio de la alumna JASMIN SOLIS con %d notas es %d
puntos,BUENO',n,p)
else
fprintf('el promedio de la alumna JASMIN SOLIS con %d notas es %d
puntos,EXCELENTE',n,p)
end
METODOS NUMERICOS
UNIVERSIDAD NACIONAL DEL CENTRO DEL PERÚ INGENIERÍA QUIMICA
CORRIENDO PROGRAMA
ingrese el numero de notas: 3
ingrese notas: 12
ingrese notas: 13
ingrese notas: 14
el promedio de la alumna JASMIN SOLIS con 3 notas es 13
puntos,BUENO>>
8.
clc
disp('======PROGRAMA DE VELOCIDAD LINEAL=======')
disp('===AUTOR: SOLIS SANTIAGO JASMIN YANINA===')
disp('=========================================')
syms x y t
x=25*t^3+t^2+10*t-200;
disp('la primera derivada es')
v=diff(x);
disp(v)
disp('la segunda derivada es')
a=diff(v);
disp(a)
disp(' Ts Xm V A')
disp('===============================================')
for t=0:1:20;
x=25*t^3+t^2+10*t-200;
v=75*t^2 + 2*t + 10;
a=150*t + 2;
disp([t x v a])
hold on
subplot(3,1,1),plot(t,x,'r--o'),grid on,title('posicion vs tiempo');
hold on
subplot(3,1,2),plot(t,v,'k+'),grid on,title('velocidad vs tiempo');
hold on
subplot(3,1,3),plot(t,a,'m*'),grid on,title('aceleracion vs tiempo');
end
disp('=================================================')
CORRIENDO PROGRAMA
======PROGRAMA DE VELOCIDAD LINEAL=======
===AUTOR: SOLIS SANTIAGO JASMIN YANINA===
=========================================
la primera derivada es
75*t^2 + 2*t + 10
la segunda derivada es
150*t + 2
METODOS NUMERICOS
UNIVERSIDAD NACIONAL DEL CENTRO DEL PERÚ INGENIERÍA QUIMICA
Ts Xm V A
=================================
0 -200 10 2
1 -164 87 152
2 24 314 302
===================================
METODOS NUMERICOS
UNIVERSIDAD NACIONAL DEL CENTRO DEL PERÚ INGENIERÍA QUIMICA
9.
clc
disp('====PROGRAMA PARA HALLAR LA SUMA====')
disp('====AUTOR: SOLIS SANTIAGO JASMIN YANINA====')
disp('===========================================')
n=input('ingrese el valor de terminos: ');
x=0;
disp('=========================')
fprintf('TABLA DE LA SUMA DEL:%d',n)
while x<12
x=x+1;
s=x+n;
fprintf('\n%d+%d=%d\n',x,n,s)
end
disp('===========================')
METODOS NUMERICOS
UNIVERSIDAD NACIONAL DEL CENTRO DEL PERÚ INGENIERÍA QUIMICA
CORRIENDO PROGRAMA
ingrese el valor de terminos: 6
=========================
TABLA DE LA SUMA DEL:6
1+6=7
2+6=8
3+6=9
4+6=10
5+6=11
6+6=12
7+6=13
8+6=14
9+6=15
10+6=16
11+6=17
12+6=18
===========================
10.
clc
disp('==================================')
disp('+++++ DETERMINACION DEL PH +++++++')
disp('==================================')
PH=input('==>Ingrese el Ph de la sustancia: ');
if PH==7;
disp('El Ph=7 indica la neutralidad')
disp('alcalinas a las que tienen Ph mayores a 7.')
else
if PH>7
fprintf('\nEl Ph de la sustancia es %d, BASICA\n',PH)
disp('alcalinas las que tienen pH mayores a 7')
else
if PH<7
fprintf('\nEl Ph de la sustancia es %d, ACIDA\n',PH)
disp('siendo acidas las soluciones con pH menores a 7')
else
end
end
end
METODOS NUMERICOS
UNIVERSIDAD NACIONAL DEL CENTRO DEL PERÚ INGENIERÍA QUIMICA
CORRIENDO PROGRAMA
==================================
+++++ DETERMINACION DEL PH +++++++
==================================
==>Ingrese el Ph de la sustancia: 6
El Ph de la sustancia es 6, ACIDA
siendo acidas las soluciones con pH menores a 7
11.
clc
disp('===========================================')
disp('PROGRAMA PARA HALLAR EL AREA DE UNA FUNCION')
disp('===========================================')
fprintf('\n');
syms x;
f=input('==>Ingrese la funcion a integrar f(x)=','s');
a=input('==>Ingrese el limite inferior: ');
b=input('==>Ingrese el limite superior: ');
fprintf('\n');
disp('================')
disp('HALLANDO EL AREA')
disp('================')
disp('LA INTEGRAL ES');
A=int(f,x,a,b);
qw=eval(A);
de=abs(qw);
disp(de)
m=a:0.05:b;
n=subs(f,m);
bar(m,n,'g');
hold on
plot(m,n)
xlabel('componente x')
ylabel('componente y')
title(f)
CORRIENDO PROGRAMA
===========================================
PROGRAMA PARA HALLAR EL AREA DE UNA FUNCION
===========================================
================
HALLANDO EL AREA
================
LA INTEGRAL ES
36.6667
METODOS NUMERICOS
UNIVERSIDAD NACIONAL DEL CENTRO DEL PERÚ INGENIERÍA QUIMICA
12.
clc
disp('===============================================')
disp('+++++++++ OBTENCION DE LA DERIVADA ++++++++++++')
disp('Y GRAFICAS DE LAS FUNCIONES: INICIAL Y DERIVADA')
disp('===============================================')
fprintf('\n');
syms x y
A=input('==>Ingrese la funcion: ');
B=diff(A);
fprintf('\n');
disp('La derivada de la funcion serà')
disp(B)
fprintf('\n');
disp('A continuacion se mostraran las graficas')
fprintf('\n');
disp('Primero de la funcion inicial')
fprintf('\n');
disp('Luego de la funcion derivada')
fprintf('\n');
subplot(1,2,1),ezplot(y-A),grid on
subplot(1,2,2),ezplot(y-B),grid on
METODOS NUMERICOS
UNIVERSIDAD NACIONAL DEL CENTRO DEL PERÚ INGENIERÍA QUIMICA
CORRIENDO PROGRAMA:
===============================================
+++++++++ OBTENCION DE LA DERIVADA ++++++++++++
Y GRAFICAS DE LAS FUNCIONES: INICIAL Y DERIVADA
===============================================
METODOS NUMERICOS
UNIVERSIDAD NACIONAL DEL CENTRO DEL PERÚ INGENIERÍA QUIMICA
13.
clc
disp('===============================================')
disp('+++++++++ OBTENCION DE LA DERIVADA ++++++++++++')
disp('********** PARCIAL RESPECTO A X e Y ***********')
disp('===============================================')
syms x y z
A=input('==>Ingrese la funcion: ');
B=diff(A,x);
C=diff(A,y);
disp('La derivada respecto a x es:')
disp(B)
disp('La derivada respecto a y es:')
disp(C)
disp('A continuacion se mostraran las graficas')
disp('Primero la funcion derivada respecto a x')
disp('Luego de la funcion derivada respecto a y')
subplot(1,2,1),ezplot(z-B),xlabel('eje x'),ylabel('eje y'),grid on
subplot(1,2,2),ezplot(z-C),xlabel('eje x'),ylabel('eje y'),grid on
CORRIENDO PROGRAMA
===============================================
+++++++++ OBTENCION DE LA DERIVADA ++++++++++++
********** PARCIAL RESPECTO A X e Y ***********
===============================================
==>Ingrese la funcion: sin(x)+2*y
La derivada respecto a x es:
cos(x)
La derivada respecto a y es:
2
A continuacion se mostraran las graficas
Primero la funcion derivada respecto a x
Luego de la funcion derivada respecto a y
METODOS NUMERICOS
UNIVERSIDAD NACIONAL DEL CENTRO DEL PERÚ INGENIERÍA QUIMICA
14.
clc
disp('====================================')
disp('PROGRAMA DE ENCUENTRO DE DOS MOVILES')
disp('====================================')
da=0;
db=0;
t=0;
v1=input('=>Ingrese la velocidad del movil 1: ');
while v1<=0
disp('ingrese velocidades positivas')
v1=input('=>Ingrese la velocidad del movil 1: ');
end
v2=input('=>Ingrese la velocidad del movil 2: ');
while v2<=0
disp('ingrese velocidades positivas')
v1=input('=>Ingrese la velocidad del movil 2: ');
end
d=input('=>Ingrese la distancia de separacion: ');
while d<=0
disp('ingrese velocidades positivas')
d=input('=>Ingrese la distancia de separacion: ');
end
disp('==========================')
disp(' t da db d')
disp('==========================')
disp([t da db d])
while da+db<d
t=t+1;
da=v1*t;
db=v2*t;
disp([t da db d])
end
disp('==========================')
fprintf('El tiempo de encuentro es: %d',t)
CORRIENDO PROGRAMA
====================================
PROGRAMA DE ENCUENTRO DE DOS MOVILES
====================================
=>Ingrese la velocidad del movil 1: 28
=>Ingrese la velocidad del movil 2: 15
=>Ingrese la distancia de separacion: 86
==========================
t da db d
==========================
0 0 0 86
1 28 15 86
2 56 30 86
==========================
El tiempo de encuentro es: 2>>
METODOS NUMERICOS
UNIVERSIDAD NACIONAL DEL CENTRO DEL PERÚ INGENIERÍA QUIMICA
15.
clc
disp('-----------------------------')
disp('PROGRAMA DE MODELO POLINOMIAL')
disp('-----------------------------')
t=input('=>Ingrese el tiempo(s): ');
T=input('=>Ingrese las temperaturas(ºC): ');
coef=polyfit(t,T,2);
a=coef(1);
b=coef(2);
c=coef(3);
T2=a*t.^2+b*t+2;
plot(t,T2,t,T,'r*')
title('REGRESION LINEAL')
xlabel('TIEMPO EN SEGUNDOS')
ylabel('TEMPERATURA EN ºC')
text(3,68,'T(t)=a*t.^2+b*t+2')
CORRIENDO PROGRAMA
----------------------------
PROGRAMA DE MODELO POLINOMIAL
-----------------------------
=>Ingrese el tiempo(s): 0:5
=>Ingrese las temperaturas(ºC): [0 20 60 68 77 110]
METODOS NUMERICOS
UNIVERSIDAD NACIONAL DEL CENTRO DEL PERÚ INGENIERÍA QUIMICA
16.
clc
format short
disp('=====================================================')
disp('PROGRAMA PARA HALLAR LA CANTIDAD NECESARIA DE Ca(OH)2')
disp('=====================================================')
fprintf('\n');
v=input('=>Ingrese el volumen: ');
PM=input('=>Ingrese el peso molecular: ');
M=input('=>Ingrese la molaridad: ');
while M<=0
disp('No se puede trabajar con este valor')
M=input('=>Ingrese la molaridad: ');
end
W=PM*M*v;
fprintf('La cantidad necesaria de Ca(OH)2 en gramos es: %0.4f',W)
CORRIENDO PROGRAMA
=====================================================
PROGRAMA PARA HALLAR LA CANTIDAD NECESARIA DE Ca(OH)2
=====================================================
17.
clc
disp('*** PROGRAMA PARA HALLAR LA GRAFICA DE ****')
disp('***********PROCESO ISOBARICO***************')
p=input('=>Ingrese el valor de la Presion(Pa): ');
while p<=0
disp('La presion no debe de ser negativa: ');
p=input('=>Ingrese el valor de la Presion(Pa): ');
end
v1=input('=>Ingrese el valor del volumen(m^3): ');
while v1<0
disp('el volumen no puede ser negativo')
v1=input('=>Ingrese el valor del volumen(m^3): ');
end
t=input('=>Ingrese el valor de la temperatura(K): ');
Q=input('=>Ingrese el valor del calor entregado(J): ');
for t2=0:10:t
v2=(v1*t2)/t;
W=p*(v2-v1);
U=Q-W;
plot(v2,t2,'or')
title('Volumen vs Temperatura')
xlabel('Volumen')
ylabel('Temperatura')
hold on
grid on
end
METODOS NUMERICOS
UNIVERSIDAD NACIONAL DEL CENTRO DEL PERÚ INGENIERÍA QUIMICA
CORRIENDO PROGRAMA
*** PROGRAMA PARA HALLAR LA GRAFICA DE ****
***********PROCESO ISOBARICO***************
=>Ingrese el valor de la Presion(Pa): 2
=>Ingrese el valor del volumen(m^3): 3
=>Ingrese el valor de la temperatura(K): 600
=>Ingrese el valor del calor entregado(J): 500
18.
clc
disp('*** PROGRAMA PARA HALLAR LA GRAFICA DE ****')
disp('***********PROCESO ISOTERMICO***************')
Q=input('=>Ingrese el calor(J): ');
v0=input('=>Ingrese el valor de del volumen inicial: ');
p1=input('=>Ingrese el valor de la presion inicial: ');
vf=input('=>Ingrese el valor del volumen final: ');
disp('==================================================')
disp(' U W P2 V')
disp('==================================================')
for v=v0:10:vf
p2=(p1*v0)*v;
W=Q;
U=0;
disp([U W p2 v])
plot(p2,v,'*')
title('presion vs volumen')
xlabel('presion')
ylabel('volumen')
hold on
grid on
end
disp('==================================================')
METODOS NUMERICOS
UNIVERSIDAD NACIONAL DEL CENTRO DEL PERÚ INGENIERÍA QUIMICA
CORRIENDO PROGRAMA:
*** PROGRAMA PARA HALLAR LA GRAFICA DE ****
***********PROCESO ISOTERMICO***************
=>Ingrese el calor(J): 600
=>Ingrese el valor de del volumen inicial: 10
=>Ingrese el valor de la presion inicial: 6
=>Ingrese el valor del volumen final: 120
===============================
U W P2 V
===============================
0 600 600 10
0 600 1200 20
0 600 1800 30
0 600 2400 40
0 600 3000 50
0 600 3600 60
0 600 4200 70
0 600 4800 80
0 600 5400 90
=================================
METODOS NUMERICOS
UNIVERSIDAD NACIONAL DEL CENTRO DEL PERÚ INGENIERÍA QUIMICA
19.
clc
disp('*** PROGRAMA PARA HALLAR LA GRAFICA DE ****')
disp('***********PROCESO ISOCORICO***************')
Q=input('=>Ingrese el valor del calor(J): ');
p1=input('=>Ingrese el valor de la presion inicial: ');
t0=input('=>Ingrese el valor de la temperatura inicial: ');
tf=input('=>Ingrese el valor de la temperatura final: ');
for t=t:10:tf
p2=(p1*t)/t0;
W=0;
U=Q;
plot(p2,t,'+')
title('presion vs temperatura')
xlabel('presion')
ylabel('temperatura')
hold on
grid on
end
CORRIENDO PROGRAMA
*** PROGRAMA PARA HALLAR LA GRAFICA DE ****
***********PROCESO ISOCORICO***************
=>Ingrese el valor del calor(J): 600
=>Ingrese el valor de la presion inicial: 4
=>Ingrese el valor de la temperatura inicial: 300
=>Ingrese el valor de la temperatura final: 420
METODOS NUMERICOS
UNIVERSIDAD NACIONAL DEL CENTRO DEL PERÚ INGENIERÍA QUIMICA
clc
disp('+++++++++++++++++++++++++++++++++++++++++++++++++++++++++')
disp(' PROGRAMA PARA HALLAR EL AREA POR EL METODO TRAPEZOIDAL ')
disp('+++++++++++++++++++++++++++++++++++++++++++++++++++++++++')
f=input('=>Ingrese la funcion f(x): ');
a=input('=>Ingrese el limite inferior: ');
b=input('=>Ingrese el limite superior: ');
n=input('=>Ingrese el numero de iteraciones: ');
h=(a-b)/n;
x=b:h:a;
fx=eval(f);
y=abs(fx);
A=y(1)+y(n+1);
B=4*sum(y(2:2:n));
C=2*sum(y(3:2:n-1));
integral=(h/3)*(A+B+C);
fprintf('El area es: %12.6f\n',integral)
%GRAFICA
subplot(1,2,1),plot(x,fx,'+')
subplot(1,2,2),bar(x,fx,'g')
CORRIENDO PROGRAMA
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
PROGRAMA PARA HALLAR EL AREA POR EL METODO TRAPEZOIDAL
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
=>Ingrese la funcion f(x): x.^2+5*x
=>Ingrese el limite inferior: 4
=>Ingrese el limite superior: 0
=>Ingrese el numero de iteraciones: 8
METODOS NUMERICOS