How can I get measured data and simulated data to match?

I have some measured data and some simulated data and I have to get the best match with the least square method. I want to multiplicate the simulated data with a variable and add a variable to accomplish this.
Is there already a program for this, respectively how could I solve this?

 Accepted Answer

If
[ I N ] = size(measured)
Solve the matrix equation
W*[ ones(1,N); simulated ] = measured

3 Comments

I don't think Matlab can solve this, there are more equations than variables. And where does least square come in?
To complete Greg's code:
L = [ ones(1,N); simulated];
W = measured / L;
The least-squares fitting is implicitly done by Matlab in the matrix division (/). This works even if there are more equations than variables.
Thank you both very much, it works perfectly :-)

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!