Académique Documents
Professionnel Documents
Culture Documents
1. Representacin de un polinomio
>> p=[5 1 3 4]
PRACTICA
p=
5 1 3 4
>> r=roots(p)
r=
0.2850 + 0.9786i
0.2850 - 0.9786i
-0.7700
2.evaluacion de un polinomio
>> p=[5 1 3 4]
p=
5 1 3 4
>>xi=2.2;
>>yi=polyval(p,xi)
yi =
68.6800
>> x=[1.1,2.5,3.6,5.2]
x=
>> y=[3.665,4.367,4.341,2.017]
y=
>> a=polyfit(x,y,length(x)-1)
a=
X=[0.0,0.25,0.5,0.75,1.0];
Interpolacinde grado 4,que pasa por los puntos(0.0 , 0,916), (0.25 , 0,8109), (0.5 ,
0,6931),(0.75 , 0,5596), (1.0 , 0,4055).
>> x=[0.0,0.25,0.5,0.75,1.0]';
y=[0.916,0.8109,0.6931,0.5596,0.4055]';
yi=interp1(x,y,xi,'linear');
>> [xi,yi]
ans =
0.2700 0.8015
0.5300 0.6771
0.6500 0.6130
0.7700 0.5473
GRAFICOS BIDIMENSIONALES
5.graficar los puntos (3,2),(5,0),(2,3),(1,4),(4,1)
>>plot(x,y)
.
close
plot(x,y)
grid
xlabel('x');ylabel('y')
7.Graficadec dos funciones,y=sin(x);z=cos(x)
>> x=0:pi/20:4*pi;
>>y=sin(x); z=cos(x);
>>plot(x,y,'.',x,z,'-')
>>grid
GRAFICA DE ECUACION NO LINEAL
8.Graficar f ( x )=cos (x)cosh ( x)+1
>> x=-5:0.1:5;
>> y=cos(x).*cosh(x)+1;
>>plot(x,y);
>>grid
>>xlabel('x');ylabel('y=cos(x)*cosh(x)+1')
9.GRAFICAS , INTERPOLACION CON POLINOMIOS DE GRADO 5 Y 10
>> x=0:10;
>>xx=0:0.1:10;
>> y=sin(x);
>> p5=polyfit(x,y,5);
>> p10=polyfit(x,y,10);
>> plot(x,y,'o',xx,polival(p5,xx),'-',x,y,'y',xx,polyval(p10,xx),'.')
>>xx=2:0.1:5;
>>plot(xx,csapi(x,y,xx),'k-',x,y,'ro'),grid
>>title('spline con 3 puntos')
>>xx=[1:0.1:5;]
xx =
Columns 1 through 7
Columns 8 through 14
Columns 15 through 21
Columns 22 through 28
3.1000 3.2000 3.3000 3.4000 3.5000 3.6000 3.7000
Columns 29 through 35
Columns 36 through 41
>>plot(xx,csapi(x,y,xx),'k-',x,y,'ro')
>>grid
>>plot(x1,y1,'x',x2,y2,'+',x3,y3,'.')
>> xx1=-2:0.1:2;
>> xx2=2:0.1:3;
>> xx3=-2:0.1:3;
>>
plot(xx1,csapi(x1,y1,xx1),'k-',x1,y1,'ro'xx2,csapi(x2,y2,xx2),'k-',x2,y2,'ro',xx3,csapi(x3,y3,xx3),'k-',x3,
y3,'ro')
13.-ECUACION NO LINEAL
>> f=0.5*exp(x/3)-sin(x);
>> close
>>plot(x,f)
>>grid
>> x=-5:0.1:10;
>> f=inline('0.5*exp(x73)-sin(x)')
f=
Inlinefunction:
f(x,x73) = 0.5*exp(x73)-sin(x)
>>fzero(f,0.5)
14.-Segunda forma con el mtodo de newton:
>> x=[0:0.2:2];
>> y=[-0.3:0.2:0.3];
>> y=0.5*exp(x/3)-sin(x);
>>close
>>plot(x,y)
>>grid
>>sym x;
( x2 )2 + ( x2 y3+2 x )25=0
2 ( x 3 )2+ ( y /3 )24=0
Grfica del sistema:
>> a=-4:0.1:8;b=-8:0.1:8;[x,y]=meshgrid(a,b);
>> f1=(x-2).^2+(y-3+2*x).^2-5;f2=2*(x-3).^2+(y/3).^2-4;
>>close
>>contour(x,y,f2,[0,0],'k');
>> f=inline('[x(1)-2).^2+(x(2)-3+2*x(1)).^2-5;2*(x(1)-3).^2+(x(2)/3).^2-4]')
f=
Inlinefunction:
f(x) = [x(1)-2).^2+(x(2)-3+2*x(1)).^2-5;2*(x(1)-3).^2+(x(2)/3).^2-4]
x=fsolve(f,[1.5,-3],optimset('fsolve'))
>> f=[x(2)-x(1).^2;x(1).^2+x(2).^2-4]
f=
-20
28
>> X0=[1.5,-3];
>> X=fsolve('experimentro1',X0)