Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %*****************AJUSTE POLINOMIAL POR MÍNIMOS CUADRADOS***************
- clc
- clear all
- h=[1,2,3,4,5,6,7,8,9,10,11,12];
- d=[1.6,2.08,5.12,4.86,3.52,2.95,2.60,1.97,1.68,1.44,1.53,1.75];
- %plot(l,p,figura,tamaño de la figura,tamaño,color de relleno, color, color del borde, color)
- plot(h,d,'o','MarkerSize',4,'MarkerFaceColor','r','MarkerEdgeColor','r')
- %suma de todas los elementos de un vector
- format long
- A=[length(h), sum(h), sum(h.^2); sum(h), sum(h.^2), sum(h.^3);sum(h.^2), sum(h.^3), sum(h.^4)];
- B=[sum(d);sum(d.*h);sum(d.*h.^2)];
- x=inv(A)*B; %valores a0 a1 y a2
- %extraccion de coeficientes del modelo
- a_0=x(1);
- a_1=x(2);
- a_2=x(3);
- syms ll
- %grado 3
- %suma de todas los elementos de un vector
- format long
- A=[length(h), sum(h), sum(h.^2), sum(h.^3); sum(h), sum(h.^2), sum(h.^3), sum(h.^4);sum(h.^2), sum(h.^3), sum(h.^4), sum(h.^5);sum(h.^3),sum(h.^4), sum(h.^5), sum(h.^6)];
- B=[sum(d);sum(d.*h);sum(d.*h.^2);sum(d.*h.^3)];
- x=inv(A)*B; %valores a0 a1 y a2
- %extraccion de coeficientes del modelo
- a_0=x(1);
- a_1=x(2);
- a_2=x(3);
- a_3=x(4);
- syms ll
- %POLINOMIO DE GRADO 3
- P_3=a_3*ll^3+a_2*ll^2+a_1*ll+a_0;
- %GRAFICANDO
- hold on
- a2=ezplot(P_3,[0,max(h)]);
- set(a2,'Color','b');
- legend('Pts. experimentales', 'P_3(ll)');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement