Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
inverse of non square matrix

Subject: inverse of non square matrix

From: hrushi

Date: 16 Jul, 2005 17:56:47

Message: 1 of 9

i need to calculate inverse of a non square matrix can any one tell me
hot it can be done in matlab.
regards,
hrushi

Subject: inverse of non square matrix

From: Brett Shoelson

Date: 16 Jul, 2005 21:03:31

Message: 2 of 9

hrushi wrote:
>
>
> i need to calculate inverse of a non square matrix can any one tell
> me
> hot it can be done in matlab.
> regards,
> hrushi

One of MATLAB's failings, I'm afraid, is that it can't do the
impossible.
Brett

Subject: inverse of non square matrix

From: Dan Hensley

Date: 16 Jul, 2005 19:22:39

Message: 3 of 9

On Sat, 16 Jul 2005 17:56:47 -0700, hrushi wrote:

> i need to calculate inverse of a non square matrix can any one tell me
> hot it can be done in matlab.
> regards,
> hrushi

help pinv

Dan

Subject: inverse of non square matrix

From: Greg Heath

Date: 17 Jul, 2005 01:14:09

Message: 4 of 9

hrushi wrote:
> i need to calculate inverse of a non square matrix can any one tell me
> hot it can be done in matlab.
> regards,
> hrushi

The inverse of a nonsquare matrix cannot exist because B,
the inverse of A, must satisfy A*B=B*A. However, when A is
nonsquare, this is impossible because the two expressions
have different dimensions.

Every matrix A does have a pseudoinverse B (usually written
as A^# or A^+) that satisfies A*B and B*A are Hermetian and
A*B*A = A, B*A*B = B.

In MATLAB B = pinv(A).

The LMSE solution to the equation A*x = y is x = pinv(A)*y.

Google on "definition pseudoinverse: for more details.

Hope this helps.

Greg

Subject: inverse of non square matrix

From: Nelson

Date: 17 Jul, 2005 17:45:54

Message: 5 of 9

hrushi wrote:
>
>
> i need to calculate inverse of a non square matrix can any one tell
> me
> hot it can be done in matlab.
> regards,
> hrushi
>
>

While a true inverse does not exist, there are techniques that are
frequently used to give a least squares best estimate for such
problems.

When you have the equation: Ax = b, and A is not square the most
common solution is obtained by

x = inv(A' * A) * A' * b

This does not always work since A' * A may have zero eigenvalues
(primarily occurs when rows of A are less than columns of A). If the
technique listed above is not sufficient for your needs let me know.
I have written my own linear solver routine that will find either a
true inverse or the least squares best approximation of an inverse
for any matrix (including those with zero eigenvalues).

Subject: inverse of non square matrix

From: Randy Poe

Date: 17 Jul, 2005 15:38:59

Message: 6 of 9



Dan Hensley wrote:
> On Sat, 16 Jul 2005 17:56:47 -0700, hrushi wrote:
>
> > i need to calculate inverse of a non square matrix can any one tell me
> > hot it can be done in matlab.
> > regards,
> > hrushi
>
> help pinv

>From a couple of other threads started by the same poster
on the same question, it is clear that what he wants to
do has nothing to do with matrix inversion.

He wants 1./a for a vector a.

             - Randy

Subject: inverse of non square matrix

From: Greg Heath

Date: 21 Jul, 2005 12:15:22

Message: 7 of 9



Nelson wrote:
> hrushi wrote:
> >
> >
> > i need to calculate inverse of a non square matrix can any one tell
> > me hot it can be done in matlab.
> > regards,
> > hrushi
>
> While a true inverse does not exist, there are techniques that are
> frequently used to give a least squares best estimate for such
> problems.
>
> When you have the equation: Ax = b, and A is not square the most
> common solution is obtained by
>
> x = inv(A' * A) * A' * b

Not in MATLAB. The most common solution is

x = A\b

> This does not always work since A' * A may have zero eigenvalues
> (primarily occurs when rows of A are less than columns of A). If the
> technique listed above is not sufficient for your needs let me know.
> I have written my own linear solver routine that will find either a
> true inverse or the least squares best approximation of an inverse
> for any matrix (including those with zero eigenvalues).

Not needed. Just use

x = pinv(A)*b

Hope this helps.

Greg

Subject: inverse of non square matrix

From: hrushi

Date: 21 Jul, 2005 13:35:18

Message: 8 of 9

thankyou for sharing that information with me.although the above
mentioned technique was able to solve my problem,i would be delighted
if you could send me your code, in case i run in to similar problem in
future.
currentlyi am struggling upon another problem on which i would welcome
any suggestions that you might have.

i have been using randn functn to generate random variables of zeromean
and unit variance , but now i have to generate random variables which
will have mean > 0 and variance > 1, if you know any functions that are
able to generate suh data please tell me the function.
regards,
hrushi

Subject: inverse of non square matrix

From: Greg Heath

Date: 23 Jul, 2005 15:09:39

Message: 9 of 9



hrushi wrote:
> thankyou for sharing that information with me.although the above
> mentioned technique was able to solve my problem,i would be delighted
> if you could send me your code, in case i run in to similar problem in
> future.

help pinv

> currentlyi am struggling upon another problem on which i would welcome
> any suggestions that you might have.
>
> i have been using randn functn to generate random variables of zeromean
> and unit variance , but now i have to generate random variables which
> will have mean > 0 and variance > 1, if you know any functions that are
> able to generate suh data please tell me the function.
> regards,
> hrushi

z = m + s*randn(1,n);

Hope this helps.

Greg

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us