function lotecomplejo [t,x]=ode45(@lote,[0 2],[16 0 0 0]) subplot(4,1,1); plot(t,x(:,1)) subplot(4,1,2); plot(t,x(:,2)) subplot(4,1,3); plot(t,x(:,3)) subplot(4,1,4); plot(t,x(:,4)) function dx=lote(t,x) % definicion de parametros k1=5; k2=4; k3=3; k4=3; dx=zeros(4,1); % ecuaciones de diseño (balances de masa), x1 = Ca, x2 = Cb, x3 = Cc, x4 = Cd dx(1) = - k1*x(1); dx(2) = k1*x(1) - k2*x(2) + k3*x(3) - k4*x(2); dx(3) = k2*x(2) - k3*x(3); dx(4) = k4*x(2);
videotutoriales de matlab, octave, numpy, python, POA, algoritmia, simulacion de procesos en ingenieria quimica, y algo de ingenieria quimica
miércoles, 1 de julio de 2015
Ejemplo de un modelo de reactor lote. En Matlab
martes, 30 de junio de 2015
martes, 23 de junio de 2015
martes, 17 de marzo de 2015
lunes, 12 de enero de 2015
Método de Regula Falsi en Matlab
Función principal
function []=regu_fal(x1, x2, n); fx1=f(x1); fx2=f(x2); c = x2 - ((f(x2)*(x2-x1))/(f(x2) - f(x1))) fc=f(c) if fx1*fx2<0; for i=1:n if fc<0 x1=c; fx1=f(x1); c = x1 - (fx1*(x1-x2)/(fx1-fx2)) fc = f(c) else x2=c; fx2=f(x2); c = x2 - (fx2*(x2-x1)/(fx2-fx1)) fc = f(c) end end else disp('Error en los Valores X1, X2'); end end
Ecuación a resolver.
function fx = f(x); fx = x^3-9*x+1; %% puedes cambiar por la funcion que gustes return;
martes, 30 de septiembre de 2014
Interpolacion por el Método de Newton
#include<stdio.h> #include<conio.h> #include<math.h> #include<process.h> #include<string.h> void main(){ int n; int i,j; float ax[10]; float ay[10]; float y=0; float x; float h; float p; float diff[20][20]; float y1,y2,y3,y4; printf("\n Numero de Terminos: "); scanf("%d",&n); printf("\n\n Valor de X: "); for(i=0;i<n;i++){ printf("\n\n Valor de x%d: ",i+1); scanf("%f",ax[i]); } printf("\n\n Valor de Y: "); for(j=0;j<n;j++){ printf("\n\n Valor de y%d: ",i+1); scanf("%f",ay[i]); } printf("\n Valor para x: "); printf("\n Valor para y: "); scanf("%f",&x); h = ax[1]-ax[0]; for(i=0;i<n-1;i++){ diff[i][1]=ay[i+1]-ay[i]; } for(j=2;j<=4;j++){ for(i=0;i<n-j;i++){ diff[i][j]=diff[i+1][j-1]-diff[i][j-1]; } } i=0; do{ i++; }while(ax[i]<x); i--; p=(x-ax[i])/h; y1= p*diff[i-1][1]; y2=p*(p+1)*diff[i-1][2]/2; y3=(p+1)*p*(p-1)*diff[i-2][3]/6; y4 = (p+2)*(p+1)*p*(p-1)*diff[i-3][4]/24; y =ay[i]+y1+y2+y3+y4; printf(" x= %6.4f, y= 6.4%f ",x,y); printf("\n\n\n Enter para Salir"); getch(); }
Suscribirse a:
Entradas (Atom)

