Tarea 4 Metodos Numericos

6
UNIVERSIDAD AUTONOMA DE NUEVO LEON FACULTAD DE CIENCIAS QUIMICAS INGENIERIA QUIMICA “TAREA 4” NOMBRE: SERGIO FERNANDO VILLALOBOS GARZA 1495648 JORGE ADRIAN TORRES CANTU 1495878 EDSON ELEAZIB VILLEGAS MARTÍNES 1465876 SEMESTRE: 6to MATERIA: METODOS NUMERICOS MAESTRO: RICARDO GOMEZ SAN NICOLAS DE LOS GARZA, NUEVO LEON; A 22/03/13

Transcript of Tarea 4 Metodos Numericos

Page 1: Tarea 4 Metodos Numericos

UNIVERSIDAD AUTONOMA DE NUEVO LEON FACULTAD DE CIENCIAS QUIMICAS

INGENIERIA QUIMICA

“TAREA 4”

NOMBRE: SERGIO FERNANDO VILLALOBOS GARZA 1495648

JORGE ADRIAN TORRES CANTU 1495878 EDSON ELEAZIB VILLEGAS MARTÍNES 1465876

SEMESTRE: 6to

MATERIA: METODOS NUMERICOS

MAESTRO: RICARDO GOMEZ

SAN NICOLAS DE LOS GARZA, NUEVO LEON; A 22/03/13

Page 2: Tarea 4 Metodos Numericos

1. The values shown in the following table are given by Perry for the specific volume, v (ft3/lb), of superheated methane, at various temperatures and pressures. Estimate the specific volume of methane at (56.4 F, 12.7 psia), (56.4, 22.7), and (411.2,12.7). Use Lagrange or Newton interpolation.

Código en Matlab function lagrange() y=input('Ingrese el valor de la temperatura T='); x=input('Ingrese el valor de la presion P=');

v=[17.15,8.47,5.57,4.12,2.678,1.954,1.518;23.97,11.94,7.91,5.91,3.91,2.90

3,2.301;30.72,15.32,10.19,7.63,5.06,3.78,3.014;37.44,18.7,12.44,9.33,6.21

,4.65,3.71;44.13,22.07,14.70,11.03,7.34,5.50,4.40;50.83,25.42,16.94,12.71

,8.46,6.35,5.07;57.51,28.76,19.17,14.38,9.58,7.19,5.75;64.20,32.10,21.40,

16.05,10.70,8.03,6.42];

t=[-200;-100;0;100;200;300;400;500]; p=[10;20;30;40;60;80;100];

n = length(t); m = length(p);

%========================================================================

== %COEFICIENTES DE LAGRANGE PARA LAS TEMPERATURAS for k = 1:n w = 1; for j = 1:n if j~= k w =((y-t(j))/(t(k)-t(j)))*w; end end A(1,k)=w; end %========================================================================

== %COEFICIENTES DE LAGRANGE PARA LAS PRESIONES for k = 1:m

Page 3: Tarea 4 Metodos Numericos

z = 1; for j = 1:m if j~=k z = ((x-p(j))/(p(k)-p(j)))*z; end end C(1,k)=z; end %========================================================================

== %INTERPOLACION s=A*v; V=s*transpose(C); %========================================================================

== display(V) end

Respuesta

Page 4: Tarea 4 Metodos Numericos

2. Robot path planning using cubic spline. Every object having a mass is subject to the law of inertia and so its speed described by the first derivative of its displacement with respect to time must be continuous in any direction. In this context, the cubic spline having the continuous derivatives up to the second order presents a good basis for planning the robot path/trajectory. We will determine the path of a robot iin such a way that the following conditions are satisfied: -At time t= 0s, the robot starts from its home position (0,0) with zero initial velocity, passing through the intermediate point (1,1) at t = 1s and arriving at the final point (2,4) at t = 2s. -On arriving at (2,4), it stats the point at t = 2s, stopping by the intermediate point (3,3) at t = 3s and arriving at the point (4,2) at t = 4s. -On arriving at (4,2), it starts the point, passing through the intermediate point (2,1) at t = 5s and then returning to the home position (0,0) at t = 6s. More specifically, what we need is -the spline interpolation matching the three points (0,0), (1,1), (2,2) and having zero velocity at both boundary points (0,0) and (2,2), -the spline interpolation matching the three points (2,2), (3,3), (4,4) and having zero velocity at both boundary points (2,2) and (4,4), and -the spline interpolation matching the three points (4,4), (5,2), (6,0) and having zero velocity at both boundary points (4,4) and (6,0) on the tx plane. On the ty plane, we need -the spline interpolation matching the three points (0,0), (1,1), (2,4) and having zero velocity at both boundary points (0,0) and (2,4), -the spline interpolation matching the three points (2,4), (3,3), (4,2) and having zero velocity at both boundary points (2,4) and (4,2), and -the spline interpolation matching the three points (4,2), (5,1), (6,0) and having zero velocity at both boundary points (4,2) and (6,0). write a program, whose objective is to make the required spline interpolations and plot the whole robot path obtained through the interpolations on the xy-plane. Código en Matlab function [a,b,c,d]=splines3x(X) n=length(X(1,:)); for i=1:n; a(i)=X(2,i); end for i=1:n-1; h(i)=X(1,i+1)-X(1,i); end for i=2:n-1; alfa(i)=3/h(i)*(a(i+1)-a(i))-3/h(i-1)*(a(i)-a(i-1)); end l(1)=1; mu(1)=0;

Page 5: Tarea 4 Metodos Numericos

z(1)=0; for i=2:n-1; l(i)=2*(X(1,i+1)-X(1,i-1))-h(i-1)*mu(i-1); mu(i)=h(i)/l(i); z(i)=(alfa(i)-h(i-1)*z(i-1))/l(i); end l(n)=1; z(n)=0; c(n)=0; for i=n-1:-1:1; c(i)=z(i)-mu(i)*c(i+1); b(i)=(a(i+1)-a(i))/h(i)-h(i)*(c(i+1)+2*c(i))/3; d(i)=(c(i+1)-c(i))/(3*h(i)); end for i=1:n-1; x=X(1,i):0.1:X(1,i+1); y=a(i)+b(i)*(x-X(1,i))+c(i)*(x-X(1,i)).^2+d(i)*(x-X(1,i)).^3; hold on; plot(x,y,'b'); end for i=1:n; hold on; plot (X(1,i),X(2,i),'*','MarkerEdgeColor','r','LineWidth',1); title('Interpolación por "splines" de orden 3.'); end end

Respuesta X vs T

Page 6: Tarea 4 Metodos Numericos

Y vs T

X vs Y