Guillermo León Nuñez
3EV4 METODOS NUMERICOS FLORES JAIME ARMANDO
INGENIERIA ELECTRICA
clc
clear
x=[0 1 2 3 4 5];
y=[-2 -3 8 67 234 593];
plot(x,y,'o')
grid
pause
hold on
P=polyfit(x,y,4,'r')
t=0:0.001:5;
Px=P(1)*t.^4+P(2)*t.^3+P(3)*t.^2+P(4)*t+P(5);
plot(t,Px)
P=polyfit(x,y,2)
Gx=P(1)*t.^2+P(2)*t+P(3);
plot(t,Gx)
hold off
xr=roots(P)
disp('Solucion Examen')
fprintf('xr1=%.3f\n', xr(1))
fprintf('xr2=%.3f\n', xr(2))
syms t
p=[x' y']
Gx=P(1)*t.^2+P(2)*t+P(3);
A=int(Gx,0,5);
fprintf('Gx=%.1f t^4+%.1f t^3+%.1f t^2+%.1f\n', P(1),P(2),P(3),P(4),P(5))
fprintf('A=%.3f u^2\n', A)
clc
clear
x=[0 1 2 3 4 5];
y=[-2 -3 8 67 234 593];
plot(x,y,'o')
grid
pause
hold on
P=polyfit(x,y,4)
t=0:0.001:5;
Px=P(1)*t.^4+P(2)*t.^3+P(3)*t.^2+P(4)*t+P(5);
plot(t,Px)
P=polyfit(x,y,2)
Gx=P(1)*t.^2+P(2)*t+P(3);
plot(t,Gx)
hold off
xr=roots(P)
disp('Solucion Examen')
fprintf('xr1=%.3f\n', xr(1))
fprintf('xr2=%.3f\n', xr(2))
syms t
p=[x' y']
Gx=P(1)*t.^2+P(2)*t+P(3);
A=int(Gx,0,5);
fprintf('Gx=%.1f t^4+%.1f t^3+%.1f t^2+%.1f\n', P(1),P(2),P(3),P(4),P(5))
fprintf('A=%.3f u^2\n', A)