urgent please help to find the best G and A with following equations using least squares method

(1) The problem is like this
Write matlab code for this
Use least squares method to find the best G and A
There are three equations with two unknowns
G117+A(1/1.8 )=1
G85+A(1/1.6) =1
G58+A(1/1.4)=1
Solution: i think u have to write in matrix form first
Then initialise the values G as 1 and A as 1
Use the command like “MinErr(G,A)”
U will get the solution
S
please explain this...... thanks in advance

Answers (4)

It's a linear equation P*x=q.
Just solve by x=P\q

2 Comments

I don't think it's what he is looking for, because, with Least square, you can have more equations then unknown variables.
Then initialise the values G as 1 and A as 1 Use the command like “MinErr(G,A)” U will get the solution S
Because the problem is linear, you do not have to initialize an iterative least squares method. There are closed form algorithms and x=P\q invokes such methods.
If your equation is F * x = b with x=[x1;x2] your unknowns variables
x= inv(F'*F)*F'*b
Example
F=rand(3,2)
b=rand(3,1)
x= inv(F'*F)*F'*b

2 Comments

This is an inefficient way to solve, and in some cases numerically unstable, because cond(F'*F) is typically much larger than cond(F).
That's why the operation F\b is made available by matlab.

This question is closed.

Asked:

on 20 Oct 2012

Community Treasure Hunt

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

Start Hunting!