MinimoCuadrados.m - clc clear all n=input'Ingrese el numero de puntos a evaluar%pedir los puntos for i=1:n datox =sprintf'Ingrese los valores de x%d)= i

• 1

This preview shows page 1 out of 1 page.

clc clear all n=input('Ingrese el numero de puntos a evaluar'); %pedir los puntos for i=1:n datox =sprintf('Ingrese los valores de x(%d)=', i); x(i)=input(datox); end for i=1:n datoy =sprintf('Ingrese los valores de y(%d)=', i); y(i)=input(datoy); end X=[x;y]; n=length(X(1,:)); A=0; B=0; C=0; D=0; for i=1:n; A=A+X(1,i); B=B+X(2,i); C=C+(X(1,i))^2; D=D+X(1,i)*X(2,i); end m=(n*D-A*B)/(n*C-A^2);

Unformatted text preview: b=(C*B-D*A)/(n*C-A^2); for i=1:n; hold on; plot(X(1,i),X(2,i),':rs','LineWidth',2,... 'MarkerFaceColor','g',... 'MarkerSize',10) x(1,i)=X(1,i); y(1,i)=m*X(1,i)+b; % plot(x,y,'b') plot(x,y,':rs','LineWidth',2,... 'MarkerFaceColor','r',... 'MarkerSize',10) title('Aproximaci n lineal por m nimos cuadrados') � � end...
View Full Document

• Fall '17
• SOLO LIBROS

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern