Jump to content

Help with some MATLAB code


Bier

Recommended Posts

I've made this code

x=[1.02,.95,.87,.77,.67,.56,.44,.3,.16,.01]';
y=[.38,.32,.27,.22,.18,.15,.13,.12,.13,.15]';
plot(x,y)
x2=x.^2;
A=[y.^2,x.*y,x,y,ones(10,1)];
z=A\x2
hold on

xp=0:.001:1;
yp=0:.001:1;

plot(z(1)*yp.^2+z(2)*xp.*yp+z(3)*xp+z(4)*yp+z(5),xp.^2)

It's supposed to solve the equation a*y^2 + b*x*y + c*x + d*y + e = x^2 using least squares and then plot the solution together with the actual measured values (x and y). Why is the least squares solution a bit of? I suppose I've made some error somewhere.

matl.png

namnlskopia.jpg
Link to comment
Share on other sites

Sweet code bro. Too bad I'm not interested in buying a 400 dollar license to help you out, and I don't think anyone else is willing to either.

 

Can you use an open source alternative like Gretl?

 

And what is the estimated value of your residuals?

newsigh.jpg
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.