http://www.mathworks.com/matlabcentral/newsreader/view_thread/247372
MATLAB Central Newsreader  solve command
Feed for thread: solve command
enus
©19942015 by MathWorks, Inc.
webmaster@mathworks.com
MATLAB Central Newsreader
http://blogs.law.harvard.edu/tech/rss
60
MathWorks
http://www.mathworks.com/images/membrane_icon.gif

Tue, 24 Mar 2009 07:34:03 +0000
solve command
http://www.mathworks.com/matlabcentral/newsreader/view_thread/247372#637158
Shane
Hi,<br>
i hav got the following matter:<br>
i need a solve commend in matlab for the equation "A*(R*x)b=0".<br>
A and R are a (n x n) matrix and b is a column vector. x is also a column vector, which has got n different variables, and is demanded. <br>
Can anyone help me?<br>
<br>
Shane

Tue, 24 Mar 2009 09:12:01 +0000
Re: solve command
http://www.mathworks.com/matlabcentral/newsreader/view_thread/247372#637170
us
"Shane"<br>
> i need a solve commend in matlab for the equation "A*(R*x)b=0".<br>
> A and R are a (n x n) matrix and b is a column vector. x is also a column vector, which has got n different variables, and is demanded...<br>
<br>
one of the solutions<br>
<br>
f=sym('a*(b*x)c=0');<br>
a=magic(3);<br>
b=magic(3);<br>
c=magic(3);<br>
fs=solve(f);<br>
r=subs(fs,{'a','b','c'},{a,b,c})<br>
%{<br>
% r =<br>
0.125 1 0.16667<br>
0.33333 0.2 0.14286<br>
0.25 0.11111 0.5<br>
%}<br>
% check<br>
a.*(b.*r)c<br>
%{<br>
% ans =<br>
0 0 0<br>
0 0 0<br>
0 0 0<br>
%}<br>
<br>
us

Tue, 24 Mar 2009 17:32:16 +0000
Re: solve command
http://www.mathworks.com/matlabcentral/newsreader/view_thread/247372#637325
Roger Stafford
"Shane " <black.gentz@hotmail.de> wrote in message <gqa2db$rhj$1@fred.mathworks.com>...<br>
> Hi,<br>
> i hav got the following matter:<br>
> i need a solve commend in matlab for the equation "A*(R*x)b=0".<br>
> A and R are a (n x n) matrix and b is a column vector. x is also a column vector, which has got n different variables, and is demanded. <br>
> Can anyone help me?<br>
> Shane<br>
<br>
I am not sure what your problem is, Shane. Matrix multiplication obeys the associative law, so A*(R*x) is equal to (A*R)*x. Why not just do this:<br>
<br>
x = (A*R)\b;<br>
<br>
It is a standard problem of n linear equations in n unknowns. If A*R is nonsingular it has a unique solution.<br>
<br>
Roger Stafford

Wed, 25 Mar 2009 08:37:01 +0000
Re: solve command
http://www.mathworks.com/matlabcentral/newsreader/view_thread/247372#637485
Shane
"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <gqb5f0$cuc$1@fred.mathworks.com>...<br>
<br>
> I am not sure what your problem is, Shane. Matrix multiplication obeys the associative law, so A*(R*x) is equal to (A*R)*x. Why not just do this:<br>
> <br>
> x = (A*R)\b;<br>
> <br>
> It is a standard problem of n linear equations in n unknowns. If A*R is nonsingular it has a unique solution.<br>
> <br>
> Roger Stafford<br>
<br>
my problem is, that i cant build up the inverse matrix of R and therefor i need a solve command.

Wed, 25 Mar 2009 09:01:39 +0000
Re: solve command
http://www.mathworks.com/matlabcentral/newsreader/view_thread/247372#637494
Torsten Hennig
> "Roger Stafford"<br>
> <ellieandrogerxyzzy@mindspring.com.invalid> wrote in<br>
> message <gqb5f0$cuc$1@fred.mathworks.com>...<br>
> <br>
> > I am not sure what your problem is, Shane.<br>
> Matrix multiplication obeys the associative law, so<br>
> o A*(R*x) is equal to (A*R)*x. Why not just do this:<br>
> > <br>
> > x = (A*R)\b;<br>
> > <br>
> > It is a standard problem of n linear equations in n<br>
> unknowns. If A*R is nonsingular it has a unique<br>
> solution.<br>
> > <br>
> > Roger Stafford<br>
> <br>
> my problem is, that i cant build up the inverse<br>
> matrix of R and therefor i need a solve command.<br>
<br>
x = (A*R)\b _is_ the command to solve the equation<br>
A*(R*x)  b = 0 for x.<br>
<br>
Of course, you could also solve in two steps for x:<br>
y = A\b<br>
x = R\y.<br>
<br>
Best wishes<br>
Torsten.

Wed, 25 Mar 2009 09:27:01 +0000
Re: solve command
http://www.mathworks.com/matlabcentral/newsreader/view_thread/247372#637502
Shane
Torsten Hennig <Torsten.Hennig@umsicht.fhg.de> wrote in message <30971896.1237971730030.JavaMail.jakarta@nitrogen.mathforum.org>...<br>
> > "Roger Stafford"<br>
> > <ellieandrogerxyzzy@mindspring.com.invalid> wrote in<br>
> > message <gqb5f0$cuc$1@fred.mathworks.com>...<br>
> > <br>
> > > I am not sure what your problem is, Shane.<br>
> > Matrix multiplication obeys the associative law, so<br>
> > o A*(R*x) is equal to (A*R)*x. Why not just do this:<br>
> > > <br>
> > > x = (A*R)\b;<br>
> > > <br>
> > > It is a standard problem of n linear equations in n<br>
> > unknowns. If A*R is nonsingular it has a unique<br>
> > solution.<br>
> > > <br>
> > > Roger Stafford<br>
> > <br>
> > my problem is, that i cant build up the inverse<br>
> > matrix of R and therefor i need a solve command.<br>
> <br>
> x = (A*R)\b _is_ the command to solve the equation<br>
> A*(R*x)  b = 0 for x.<br>
> <br>
> Of course, you could also solve in two steps for x:<br>
> y = A\b<br>
> x = R\y.<br>
> <br>
> Best wishes<br>
> Torsten.<br>
<br>
<br>
I hav tried this sloution method, but the problem is tht the condition of Amatrix is very bad and the det(R)=0. So this solution causes to no results.

Wed, 25 Mar 2009 09:37:52 +0000
Re: solve command
http://www.mathworks.com/matlabcentral/newsreader/view_thread/247372#637505
Torsten Hennig
> Torsten Hennig <Torsten.Hennig@umsicht.fhg.de> wrote<br>
> in message<br>
> <30971896.1237971730030.JavaMail.jakarta@nitrogen.math<br>
> forum.org>...<br>
> > > "Roger Stafford"<br>
> > > <ellieandrogerxyzzy@mindspring.com.invalid> wrote<br>
> in<br>
> > > message <gqb5f0$cuc$1@fred.mathworks.com>...<br>
> > > <br>
> > > > I am not sure what your problem is, Shane.<br>
> > > Matrix multiplication obeys the associative law,<br>
> so<br>
> > > o A*(R*x) is equal to (A*R)*x. Why not just do<br>
> this:<br>
> > > > <br>
> > > > x = (A*R)\b;<br>
> > > > <br>
> > > > It is a standard problem of n linear equations<br>
> in n<br>
> > > unknowns. If A*R is nonsingular it has a unique<br>
> > > solution.<br>
> > > > <br>
> > > > Roger Stafford<br>
> > > <br>
> > > my problem is, that i cant build up the inverse<br>
> > > matrix of R and therefor i need a solve command.<br>
> > <br>
> > x = (A*R)\b _is_ the command to solve the equation<br>
> > A*(R*x)  b = 0 for x.<br>
> > <br>
> > Of course, you could also solve in two steps for x:<br>
> > y = A\b<br>
> > x = R\y.<br>
> > <br>
> > Best wishes<br>
> > Torsten.<br>
> <br>
> <br>
> I hav tried this sloution method, but the problem is<br>
> tht the condition of Amatrix is very bad and the<br>
> det(R)=0. So this solution causes to no results.<br>
<br>
If an exact solution of the equation A*(R*x)  b = 0<br>
exists, x = (A*R)\b will produce it.<br>
Otherwise, x will be an "approximate" solution, i.e.<br>
a vector which minimizes the "error" A*(R*x)  b in the Euclidean norm.<br>
<br>
Best wishes<br>
Torsten.

Wed, 25 Mar 2009 10:09:04 +0000
Re: solve command
http://www.mathworks.com/matlabcentral/newsreader/view_thread/247372#637509
Torsten Hennig
> > Torsten Hennig <Torsten.Hennig@umsicht.fhg.de><br>
> wrote<br>
> > in message<br>
> ><br>
> <30971896.1237971730030.JavaMail.jakarta@nitrogen.math<br>
> <br>
> > forum.org>...<br>
> > > > "Roger Stafford"<br>
> > > > <ellieandrogerxyzzy@mindspring.com.invalid><br>
> wrote<br>
> > in<br>
> > > > message <gqb5f0$cuc$1@fred.mathworks.com>...<br>
> > > > <br>
> > > > > I am not sure what your problem is, Shane.<br>
> > > > Matrix multiplication obeys the associative<br>
> law,<br>
> > so<br>
> > > > o A*(R*x) is equal to (A*R)*x. Why not just<br>
> do<br>
> > this:<br>
> > > > > <br>
> > > > > x = (A*R)\b;<br>
> > > > > <br>
> > > > > It is a standard problem of n linear<br>
> equations<br>
> > in n<br>
> > > > unknowns. If A*R is nonsingular it has a<br>
> unique<br>
> > > > solution.<br>
> > > > > <br>
> > > > > Roger Stafford<br>
> > > > <br>
> > > > my problem is, that i cant build up the<br>
> inverse<br>
> > > > matrix of R and therefor i need a solve<br>
> command.<br>
> > > <br>
> > > x = (A*R)\b _is_ the command to solve the<br>
> equation<br>
> > > A*(R*x)  b = 0 for x.<br>
> > > <br>
> > > Of course, you could also solve in two steps for<br>
> x:<br>
> > > y = A\b<br>
> > > x = R\y.<br>
> > > <br>
> > > Best wishes<br>
> > > Torsten.<br>
> > <br>
> > <br>
> > I hav tried this sloution method, but the problem<br>
> is<br>
> > tht the condition of Amatrix is very bad and the<br>
> > det(R)=0. So this solution causes to no results.<br>
> <br>
> If an exact solution of the equation A*(R*x)  b = 0<br>
> exists, x = (A*R)\b will produce it.<br>
> Otherwise, x will be an "approximate" solution, i.e.<br>
> a vector which minimizes the "error" A*(R*x)  b in<br>
> the Euclidean norm.<br>
> <br>
> Best wishes<br>
> Torsten.<br>
<br>
As I read in the MATLAB documentation, the backslash<br>
operation does not seem to produce a leastsquares<br>
solution in the case of square systems if the coefficient<br>
matrix is singular.<br>
<br>
Instead, you can try<br>
x = pinv(A*R)*b<br>
<br>
Best wishes<br>
Torsten.

Wed, 25 Mar 2009 10:32:02 +0000
Re: solve command
http://www.mathworks.com/matlabcentral/newsreader/view_thread/247372#637515
Bruno Luong
Torsten Hennig <Torsten.Hennig@umsicht.fhg.de> wrote in message <29391649.1237975774607.JavaMail.jakarta@nitrogen.mathforum.org>...<br>
<br>
> <br>
> As I read in the MATLAB documentation, the backslash<br>
> operation does not seem to produce a leastsquares<br>
> solution in the case of square systems if the coefficient<br>
> matrix is singular.<br>
> <br>
> Instead, you can try<br>
> x = pinv(A*R)*b<br>
> <br>
> Best wishes<br>
> Torsten.<br>
<br>
Hi Torsen,<br>
<br>
Yes, the backslash actually produces the leastsquare solution for overdetermined system (minimizing the norm of the residual, on the image space), as with pinv.<br>
<br>
However if the matrix has nontrivial kernel (different {0}), then backslash selects a solution that is usually not the minimumnorm solution (minimize the norm on the source space, but sill leastsquare solution). This is the main difference between pinv.<br>
<br>
Hope it is clear,<br>
<br>
Bruno

Wed, 25 Mar 2009 11:47:01 +0000
Re: solve command
http://www.mathworks.com/matlabcentral/newsreader/view_thread/247372#637541
Shane
"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <gqd172$fp1$1@fred.mathworks.com>...<br>
> Torsten Hennig <Torsten.Hennig@umsicht.fhg.de> wrote in message <29391649.1237975774607.JavaMail.jakarta@nitrogen.mathforum.org>...<br>
> <br>
> > <br>
> > As I read in the MATLAB documentation, the backslash<br>
> > operation does not seem to produce a leastsquares<br>
> > solution in the case of square systems if the coefficient<br>
> > matrix is singular.<br>
> > <br>
> > Instead, you can try<br>
> > x = pinv(A*R)*b<br>
> > <br>
> > Best wishes<br>
> > Torsten.<br>
> <br>
> Hi Torsen,<br>
> <br>
> Yes, the backslash actually produces the leastsquare solution for overdetermined system (minimizing the norm of the residual, on the image space), as with pinv.<br>
> <br>
> However if the matrix has nontrivial kernel (different {0}), then backslash selects a solution that is usually not the minimumnorm solution (minimize the norm on the source space, but sill leastsquare solution). This is the main difference between pinv.<br>
> <br>
> Hope it is clear,<br>
> <br>
> Bruno<br>
<br>
<br>
Thanks for the clearings.<br>
I tried to built the A Matrix in another way. So the new equation is A*x=B.<br>
But when I try to solve this problem with x=A\B or x=inv(A)*B, then the results is not quite correct. I guess it must be a rounding error or something like that.<br>
Is it possible solve this problem in another way, e.g. an iteration method??<br>
<br>
Shane

Wed, 25 Mar 2009 11:42:22 +0000
Re: solve command
http://www.mathworks.com/matlabcentral/newsreader/view_thread/247372#637542
Torsten Hennig
> <br>
> Hi Torsen,<br>
> <br>
> Yes, the backslash actually produces the leastsquare<br>
> solution for overdetermined system (minimizing the<br>
> norm of the residual, on the image space), as with<br>
> pinv.<br>
> <br>
> However if the matrix has nontrivial kernel<br>
> (different {0}), then backslash selects a solution<br>
> that is usually not the minimumnorm solution<br>
> (minimize the norm on the source space, but sill<br>
> leastsquare solution). This is the main difference<br>
> between pinv.<br>
> <br>
> Hope it is clear,<br>
> <br>
> Bruno<br>
<br>
Hi Bruno,<br>
<br>
cited from MATLAB documentation for square matrices:<br>
<br>
<a href="http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/math/f4983672.html&http">http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/math/f4983672.html&http</a>://www.google.de/search?hl=de&q=matlab+%26+linear+equations&meta=<br>
<br>
"If A is singular, the solution to Ax = b either does not exist, or is not unique. The backslash operator, A\b, issues a warning if A is nearly singular and raises an error condition if it detects exact singularity."<br>
<br>
So in the case A is singular, a solution with the <br>
backslash operator (either exact or in the leastsquares sense) can not be obtained ?<br>
<br>
Best wishes<br>
Torsten.

Wed, 25 Mar 2009 12:10:03 +0000
Re: solve command
http://www.mathworks.com/matlabcentral/newsreader/view_thread/247372#637548
Bruno Luong
Torsten Hennig <Torsten.Hennig@umsicht.fhg.de> wrote in message <13802981.1237981373076.JavaMail.jakarta@nitrogen.mathforum.org>...<br>
> > <br>
> > Hi Torsen,<br>
> > <br>
> > Yes, the backslash actually produces the leastsquare<br>
> > solution for overdetermined system (minimizing the<br>
> > norm of the residual, on the image space), as with<br>
> > pinv.<br>
> > <br>
> > However if the matrix has nontrivial kernel<br>
> > (different {0}), then backslash selects a solution<br>
> > that is usually not the minimumnorm solution<br>
> > (minimize the norm on the source space, but sill<br>
> > leastsquare solution). This is the main difference<br>
> > between pinv.<br>
> > <br>
> > Hope it is clear,<br>
> > <br>
> > Bruno<br>
> <br>
> Hi Bruno,<br>
> <br>
> cited from MATLAB documentation for square matrices:<br>
> <br>
> <a href="http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/math/f4983672.html&http">http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/math/f4983672.html&http</a>://www.google.de/search?hl=de&q=matlab+%26+linear+equations&meta=<br>
> <br>
> "If A is singular, the solution to Ax = b either does not exist, or is not unique. The backslash operator, A\b, issues a warning if A is nearly singular and raises an error condition if it detects exact singularity."<br>
> <br>
> So in the case A is singular, a solution with the <br>
> backslash operator (either exact or in the leastsquares sense) can not be obtained ?<br>
> <br>
<br>
Hi Torsen,<br>
<br>
No, "\" succeeds, even invert on degenerated matrix. Please see example below:<br>
<br>
% Column 1 and 3 are dependent,<br>
% rank A is two<br>
A= [ 1 0 1;<br>
0 1 0;<br>
0 0 0;<br>
0 0 0 ];<br>
<br>
b=(1:4).';<br>
<br>
x1=A\b % [1 2 0]'<br>
x2=pinv(A)*b %[0.5 2 0.5]'<br>
<br>
% The linear maps the solutions to two equal results<br>
% i.e., x = argmin A*x  b for both x1 and x2<br>
y1=A*x1 [1 2 0 0]'<br>
y2=A*x2 % idem as y1<br>
<br>
% x2 however is selected is minimal norm, they differ by something in <null(A)><br>
norm(x1) % 2.2361<br>
norm(x2) % 2.1213<br>
<br>
% Bruno

Wed, 25 Mar 2009 12:10:04 +0000
Re: solve command
http://www.mathworks.com/matlabcentral/newsreader/view_thread/247372#637549
Shane
"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <gqd172$fp1$1@fred.mathworks.com>...<br>
> Torsten Hennig <Torsten.Hennig@umsicht.fhg.de> wrote in message <29391649.1237975774607.JavaMail.jakarta@nitrogen.mathforum.org>...<br>
> <br>
> > <br>
> > As I read in the MATLAB documentation, the backslash<br>
> > operation does not seem to produce a leastsquares<br>
> > solution in the case of square systems if the coefficient<br>
> > matrix is singular.<br>
> > <br>
> > Instead, you can try<br>
> > x = pinv(A*R)*b<br>
> > <br>
> > Best wishes<br>
> > Torsten.<br>
> <br>
> Hi Torsen,<br>
> <br>
> Yes, the backslash actually produces the leastsquare solution for overdetermined system (minimizing the norm of the residual, on the image space), as with pinv.<br>
> <br>
> However if the matrix has nontrivial kernel (different {0}), then backslash selects a solution that is usually not the minimumnorm solution (minimize the norm on the source space, but sill leastsquare solution). This is the main difference between pinv.<br>
> <br>
> Hope it is clear,<br>
> <br>
> Bruno<br>
<br>
<br>
Thanks for the clearings.<br>
I tried to built the A Matrix in another way. So the new equation is A*x=B.<br>
But when I try to solve this problem with x=A\B or x=inv(A)*B, then the results is not quite correct. I guess it must be a rounding error or something like that.<br>
Is it possible solve this problem in another way, e.g. an iteration method??<br>
<br>
Shane

Wed, 25 Mar 2009 12:26:01 +0000
Re: solve command
http://www.mathworks.com/matlabcentral/newsreader/view_thread/247372#637552
Bruno Luong
"Shane " <black.gentz@hotmail.de> wrote in message <gqd6us$7m9$1@fred.mathworks.com>...<br>
<br>
> <br>
> <br>
> Thanks for the clearings.<br>
> I tried to built the A Matrix in another way. So the new equation is A*x=B.<br>
> But when I try to solve this problem with x=A\B or x=inv(A)*B, then the results is not quite correct. <br>
<br>
Why you think it is not correct? Usually Matlab always gives a (numerically) consistent result: leastsquare, and leastnorm when using PINV.<br>
<br>
It might not what you are expecting, but you have not told us why.<br>
<br>
>I guess it must be a rounding error or something like that.<br>
> Is it possible solve this problem in another way, e.g. an iteration method??<br>
> <br>
<br>
You could provide a tolerance in PINV, that cut the rank, or using the iterative method and let it not totally converging.<br>
<br>
But again, keep in mind that you are dealing with illposed linear system, and there are an infinity number of solutions. Matlab pick a result that you don't like, but because you had not tell it what you really want.<br>
<br>
Bruno

Wed, 25 Mar 2009 14:14:02 +0000
Re: solve command
http://www.mathworks.com/matlabcentral/newsreader/view_thread/247372#637604
Shane
"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <gqd7sp$9t2$1@fred.mathworks.com>...<br>
> "Shane " <black.gentz@hotmail.de> wrote in message <gqd6us$7m9$1@fred.mathworks.com>...<br>
> <br>
> > <br>
> > <br>
> > Thanks for the clearings.<br>
> > I tried to built the A Matrix in another way. So the new equation is A*x=B.<br>
> > But when I try to solve this problem with x=A\B or x=inv(A)*B, then the results is not quite correct. <br>
> <br>
> Why you think it is not correct? Usually Matlab always gives a (numerically) consistent result: leastsquare, and leastnorm when using PINV.<br>
> <br>
> It might not what you are expecting, but you have not told us why.<br>
> <br>
> >I guess it must be a rounding error or something like that.<br>
> > Is it possible solve this problem in another way, e.g. an iteration method??<br>
> > <br>
> <br>
> You could provide a tolerance in PINV, that cut the rank, or using the iterative method and let it not totally converging.<br>
> <br>
> But again, keep in mind that you are dealing with illposed linear system, and there are an infinity number of solutions. Matlab pick a result that you don't like, but because you had not tell it what you really want.<br>
> <br>
> Bruno<br>
<br>
<br>
The right solution of the my problem is:<br>
x=(149,344; 149,004; 156,321; 157,021; 156,568; 155,871; 155,049; 153,96; 151,631; 142,069].<br>
<br>
But with the command x=b'/A I get for x:<br>
x=[149,465; 149,995; 154,4257; 154,8244; 154,5465; 154,1209; 153,5739; 152,5583; 148,8012; 127,751]<br>
<br>
and with the command x=inv(A)*b or x=pinv(A)*b the result is:<br>
x=[149.292; 149.852; 154.273; 154.670; 154.386; 153.916; 153.086; 150.276; 135.100; 143.012]<br>
<br>
so you can see that there is a difference between each solution. My Question is if the is anothe method so solve the equation. I guess the problem is the AMatrix, because the condition is not really good, cond(A)=49,0233.

Wed, 25 Mar 2009 14:40:19 +0000
Re: solve command
http://www.mathworks.com/matlabcentral/newsreader/view_thread/247372#637614
Bruno Luong
"Shane " <black.gentz@hotmail.de> wrote in message <gqde7a$lr6$1@fred.mathworks.com>...<br>
> "Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <gqd7sp$9t2$1@fred.mathworks.com>...<br>
> > "Shane " <black.gentz@hotmail.de> wrote in message <gqd6us$7m9$1@fred.mathworks.com>...<br>
> > <br>
> > > <br>
> > > <br>
> > > Thanks for the clearings.<br>
> > > I tried to built the A Matrix in another way. So the new equation is A*x=B.<br>
> > > But when I try to solve this problem with x=A\B or x=inv(A)*B, then the results is not quite correct. <br>
> > <br>
> > Why you think it is not correct? Usually Matlab always gives a (numerically) consistent result: leastsquare, and leastnorm when using PINV.<br>
> > <br>
> > It might not what you are expecting, but you have not told us why.<br>
> > <br>
> > >I guess it must be a rounding error or something like that.<br>
> > > Is it possible solve this problem in another way, e.g. an iteration method??<br>
> > > <br>
> > <br>
> > You could provide a tolerance in PINV, that cut the rank, or using the iterative method and let it not totally converging.<br>
> > <br>
> > But again, keep in mind that you are dealing with illposed linear system, and there are an infinity number of solutions. Matlab pick a result that you don't like, but because you had not tell it what you really want.<br>
> > <br>
> > Bruno<br>
> <br>
> <br>
> The right solution of the my problem is:<br>
> x=(149,344; 149,004; 156,321; 157,021; 156,568; 155,871; 155,049; 153,96; 151,631; 142,069].<br>
<br>
And what indicated this is "more" right?<br>
> <br>
> But with the command x=b'/A I get for x:<br>
> x=[149,465; 149,995; 154,4257; 154,8244; 154,5465; 154,1209; 153,5739; 152,5583; 148,8012; 127,751]<br>
> <br>
> and with the command x=inv(A)*b or x=pinv(A)*b the result is:<br>
> x=[149.292; 149.852; 154.273; 154.670; 154.386; 153.916; 153.086; 150.276; 135.100; 143.012]<br>
<br>
I fail to see why they are not right? Both solutions satisfy A*x = b, and that's the only target of a linear inversion.<br>
<br>
> <br>
> so you can see that there is a difference between each solution. <br>
<br>
Yes, and I'm not surprised.<br>
<br>
<br>
>My Question is if the is anothe method so solve the equation. I guess the problem is the AMatrix, because the condition is not really good, cond(A)=49,0233.<br>
<br>
You can even take any combination of the three above solutions<br>
x = c1*x1 + c2*x2 + c3*x3, with sum ci = 1<br>
<br>
And you still have<br>
A*x = b.<br>
<br>
Allow me to repeat one more time: there are an infinity of solutions. If you cannot clearly *formulate* what solution is right for you, you might spend a lot of time chasing forever the algorithm that gives the "right" solution. <br>
<br>
Second alternative: you just have to accept that the solutions given by an algorithm can be also "right".<br>
<br>
Bruno

Thu, 26 Mar 2009 07:02:02 +0000
Re: solve command
http://www.mathworks.com/matlabcentral/newsreader/view_thread/247372#637830
Shane
"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <gqdfoj$es8$1@fred.mathworks.com>...<br>
> "Shane " <black.gentz@hotmail.de> wrote in message <gqde7a$lr6$1@fred.mathworks.com>...<br>
> > "Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <gqd7sp$9t2$1@fred.mathworks.com>...<br>
> > > "Shane " <black.gentz@hotmail.de> wrote in message <gqd6us$7m9$1@fred.mathworks.com>...<br>
> > > <br>
> > > > <br>
> > > > <br>
> > > > Thanks for the clearings.<br>
> > > > I tried to built the A Matrix in another way. So the new equation is A*x=B.<br>
> > > > But when I try to solve this problem with x=A\B or x=inv(A)*B, then the results is not quite correct. <br>
> > > <br>
> > > Why you think it is not correct? Usually Matlab always gives a (numerically) consistent result: leastsquare, and leastnorm when using PINV.<br>
> > > <br>
> > > It might not what you are expecting, but you have not told us why.<br>
> > > <br>
> > > >I guess it must be a rounding error or something like that.<br>
> > > > Is it possible solve this problem in another way, e.g. an iteration method??<br>
> > > > <br>
> > > <br>
> > > You could provide a tolerance in PINV, that cut the rank, or using the iterative method and let it not totally converging.<br>
> > > <br>
> > > But again, keep in mind that you are dealing with illposed linear system, and there are an infinity number of solutions. Matlab pick a result that you don't like, but because you had not tell it what you really want.<br>
> > > <br>
> > > Bruno<br>
> > <br>
> > <br>
> > The right solution of the my problem is:<br>
> > x=(149,344; 149,004; 156,321; 157,021; 156,568; 155,871; 155,049; 153,96; 151,631; 142,069].<br>
> <br>
> And what indicated this is "more" right?<br>
> > <br>
> > But with the command x=b'/A I get for x:<br>
> > x=[149,465; 149,995; 154,4257; 154,8244; 154,5465; 154,1209; 153,5739; 152,5583; 148,8012; 127,751]<br>
> > <br>
> > and with the command x=inv(A)*b or x=pinv(A)*b the result is:<br>
> > x=[149.292; 149.852; 154.273; 154.670; 154.386; 153.916; 153.086; 150.276; 135.100; 143.012]<br>
> <br>
> I fail to see why they are not right? Both solutions satisfy A*x = b, and that's the only target of a linear inversion.<br>
> <br>
> > <br>
> > so you can see that there is a difference between each solution. <br>
> <br>
> Yes, and I'm not surprised.<br>
> <br>
> <br>
> >My Question is if the is anothe method so solve the equation. I guess the problem is the AMatrix, because the condition is not really good, cond(A)=49,0233.<br>
> <br>
> You can even take any combination of the three above solutions<br>
> x = c1*x1 + c2*x2 + c3*x3, with sum ci = 1<br>
> <br>
> And you still have<br>
> A*x = b.<br>
> <br>
> Allow me to repeat one more time: there are an infinity of solutions. If you cannot clearly *formulate* what solution is right for you, you might spend a lot of time chasing forever the algorithm that gives the "right" solution. <br>
> <br>
> Second alternative: you just have to accept that the solutions given by an algorithm can be also "right".<br>
> <br>
> Bruno<br>
<br>
<br>
Hi Bruno,<br>
now I clearly understand what you mean. Thats the point, how can I say to Matlab, which solution he had to pick or rather what kind of options I have to say which solution is right for me??

Thu, 26 Mar 2009 07:33:29 +0000
Re: solve command
http://www.mathworks.com/matlabcentral/newsreader/view_thread/247372#637841
Torsten Hennig
> "Bruno Luong" <b.luong@fogale.findmycountry> wrote in<br>
> message <gqdfoj$es8$1@fred.mathworks.com>...<br>
> > "Shane " <black.gentz@hotmail.de> wrote in message<br>
> <gqde7a$lr6$1@fred.mathworks.com>...<br>
> > > "Bruno Luong" <b.luong@fogale.findmycountry><br>
> wrote in message <gqd7sp$9t2$1@fred.mathworks.com>...<br>
> > > > "Shane " <black.gentz@hotmail.de> wrote in<br>
> message <gqd6us$7m9$1@fred.mathworks.com>...<br>
> > > > <br>
> > > > > <br>
> > > > > <br>
> > > > > Thanks for the clearings.<br>
> > > > > I tried to built the A Matrix in another way.<br>
> So the new equation is A*x=B.<br>
> > > > > But when I try to solve this problem with<br>
> x=A\B or x=inv(A)*B, then the results is not quite<br>
> correct. <br>
> > > > <br>
> > > > Why you think it is not correct? Usually Matlab<br>
> always gives a (numerically) consistent result:<br>
> leastsquare, and leastnorm when using PINV.<br>
> > > > <br>
> > > > It might not what you are expecting, but you<br>
> have not told us why.<br>
> > > > <br>
> > > > >I guess it must be a rounding error or<br>
> something like that.<br>
> > > > > Is it possible solve this problem in another<br>
> way, e.g. an iteration method??<br>
> > > > > <br>
> > > > <br>
> > > > You could provide a tolerance in PINV, that cut<br>
> the rank, or using the iterative method and let it<br>
> not totally converging.<br>
> > > > <br>
> > > > But again, keep in mind that you are dealing<br>
> with illposed linear system, and there are an<br>
> infinity number of solutions. Matlab pick a result<br>
> that you don't like, but because you had not tell it<br>
> what you really want.<br>
> > > > <br>
> > > > Bruno<br>
> > > <br>
> > > <br>
> > > The right solution of the my problem is:<br>
> > > x=(149,344; 149,004; 156,321; 157,021; 156,568;<br>
> 155,871; 155,049; 153,96; 151,631; 142,069].<br>
> > <br>
> > And what indicated this is "more" right?<br>
> > > <br>
> > > But with the command x=b'/A I get for x:<br>
> > > x=[149,465; 149,995; 154,4257; 154,8244;<br>
> 154,5465; 154,1209; 153,5739; 152,5583; 148,8012;<br>
> 127,751]<br>
> > > <br>
> > > and with the command x=inv(A)*b or x=pinv(A)*b<br>
> the result is:<br>
> > > x=[149.292; 149.852; 154.273; 154.670; 154.386;<br>
> 153.916; 153.086; 150.276; 135.100; 143.012]<br>
> > <br>
> > I fail to see why they are not right? Both<br>
> solutions satisfy A*x = b, and that's the only target<br>
> of a linear inversion.<br>
> > <br>
> > > <br>
> > > so you can see that there is a difference between<br>
> each solution. <br>
> > <br>
> > Yes, and I'm not surprised.<br>
> > <br>
> > <br>
> > >My Question is if the is anothe method so solve<br>
> the equation. I guess the problem is the AMatrix,<br>
> because the condition is not really good,<br>
> cond(A)=49,0233.<br>
> > <br>
> > You can even take any combination of the three<br>
> above solutions<br>
> > x = c1*x1 + c2*x2 + c3*x3, with sum ci = 1<br>
> > <br>
> > And you still have<br>
> > A*x = b.<br>
> > <br>
> > Allow me to repeat one more time: there are an<br>
> infinity of solutions. If you cannot clearly<br>
> *formulate* what solution is right for you, you<br>
> u might spend a lot of time chasing forever the<br>
> algorithm that gives the "right" solution. <br>
> > <br>
> > Second alternative: you just have to accept that<br>
> the solutions given by an algorithm can be also<br>
> "right".<br>
> > <br>
> > Bruno<br>
> <br>
> <br>
> Hi Bruno,<br>
> now I clearly understand what you mean. Thats the<br>
> point, how can I say to Matlab, which solution he had<br>
> to pick or rather what kind of options I have to say<br>
> which solution is right for me??<br>
<br>
First you have to formulate the criterium (criteria) <br>
for a solution to be false or right for you.<br>
Then we can think about a way to tell MATLAB which <br>
solution it should select.<br>
<br>
Best wishes<br>
Torsten.

Thu, 26 Mar 2009 07:55:03 +0000
Re: solve command
http://www.mathworks.com/matlabcentral/newsreader/view_thread/247372#637846
Bruno Luong
<br>
> Hi Bruno,<br>
> now I clearly understand what you mean. Thats the point, how can I say to Matlab, which solution he had to pick or rather what kind of options I have to say which solution is right for me??<br>
<br>
Shane I invite you to medidate about this example:<br>
A = [1 0 1<br>
0 1 1]<br>
xright = [1 1 3]'<br>
b=A*xright<br>
<br>
% Try to find xright:<br>
x1 = A\b<br>
x2 = pinv(A)*b<br>
<br>
%%%%<br>
<br>
Mr S.: x1 and x2 are not right, because it is not x, which I want<br>
Mr Matlab: why? A*x1 = b and A*x2=b, they are both fine<br>
Mr S: yes but I want x, not x1 and x2<br>
Mr Matlab: Tell me more, how should I select x if you only gives me A and b?<br>
Mr S: Because... < you need to fill the rest of the story here<br>
<br>
Bruno

Thu, 26 Mar 2009 08:32:01 +0000
Re: solve command
http://www.mathworks.com/matlabcentral/newsreader/view_thread/247372#637854
Shane
<br>
> Shane I invite you to medidate about this example:<br>
> A = [1 0 1<br>
> 0 1 1]<br>
> xright = [1 1 3]'<br>
> b=A*xright<br>
> <br>
> % Try to find xright:<br>
> x1 = A\b<br>
> x2 = pinv(A)*b<br>
> <br>
> %%%%<br>
> <br>
> Mr S.: x1 and x2 are not right, because it is not x, which I want<br>
> Mr Matlab: why? A*x1 = b and A*x2=b, they are both fine<br>
> Mr S: yes but I want x, not x1 and x2<br>
> Mr Matlab: Tell me more, how should I select x if you only gives me A and b?<br>
> Mr S: Because... < you need to fill the rest of the story here<br>
> <br>
> Bruno<br>
<br>
Yes, I understand both of you now. I need more terms or conditions for x to find the right solution. Give me please more time to find more conditions for x. I hope you will help me then to "tell" Matlab these sondiotions. <br>
Thanks a lot.<br>
<br>
Shanne

Wed, 01 Apr 2009 09:12:01 +0000
Re: solve command
http://www.mathworks.com/matlabcentral/newsreader/view_thread/247372#639287
Shane
"Shane " <black.gentz@hotmail.de> wrote in message <gqfei1$d4r$1@fred.mathworks.com>...<br>
> <br>
> > Shane I invite you to medidate about this example:<br>
> > A = [1 0 1<br>
> > 0 1 1]<br>
> > xright = [1 1 3]'<br>
> > b=A*xright<br>
> > <br>
> > % Try to find xright:<br>
> > x1 = A\b<br>
> > x2 = pinv(A)*b<br>
> > <br>
> > %%%%<br>
> > <br>
> > Mr S.: x1 and x2 are not right, because it is not x, which I want<br>
> > Mr Matlab: why? A*x1 = b and A*x2=b, they are both fine<br>
> > Mr S: yes but I want x, not x1 and x2<br>
> > Mr Matlab: Tell me more, how should I select x if you only gives me A and b?<br>
> > Mr S: Because... < you need to fill the rest of the story here<br>
> > <br>
> > Bruno<br>
> <br>
> Yes, I understand both of you now. I need more terms or conditions for x to find the right solution. Give me please more time to find more conditions for x. I hope you will help me then to "tell" Matlab these sondiotions. <br>
> Thanks a lot.<br>
> <br>
> Shanne<br>
<br>
hey Guys,<br>
I find now the right solution for my problems.<br>
Thanks a lot for your helps and suggestions.<br>
<br>
Shane