From: Wendy on
Hi,

I have a (3355x2) matrix (called A) and a (3355x1) vector (called 'b'), and I am solving for x as Ax=b.

I used x=A\b. However, when I multiply A*x, the solution is very different from 'b'. Does anybody know how to solve the problem? Can I use this the optimization toolbox to solve the system of linear equations?

Thank you in advance,
Wendy
From: Matt J on
"Wendy " <wlq121(a)gmail.com> wrote in message <hljipm$isj$1(a)fred.mathworks.com>...
> Hi,
>
> I have a (3355x2) matrix (called A) and a (3355x1) vector (called 'b'), and I am solving for x as Ax=b.
>
> I used x=A\b. However, when I multiply A*x, the solution is very different from 'b'. Does anybody know how to solve the problem? Can I use this the optimization toolbox to solve the system of linear equations?
================

You did solve the problem. A\b is the least squares solution to A*x=b, so whatever x=A\b returned is the best agreement between A*x and b that was available in a least squares sense.
From: James Allison on
What is the condition of A (i.e., cond(A))? If A is poorly conditioned,
the results may be inaccurate. You could try scaling or diagonalization
of A to get more accurate results.

-James

Wendy wrote:
> Hi,
>
> I have a (3355x2) matrix (called A) and a (3355x1) vector (called 'b'),
> and I am solving for x as Ax=b.
> I used x=A\b. However, when I multiply A*x, the solution is very
> different from 'b'. Does anybody know how to solve the problem? Can I
> use this the optimization toolbox to solve the system of linear equations?
>
> Thank you in advance,
> Wendy