Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: Inverse of a matrix

Subject: Inverse of a matrix

From: Dev

Date: 24 Jun, 2008 03:27:52

Message: 1 of 3

Hi All,

I want to get the inverse of a matrix. For example, if the matrix is
PSF =(1/16)* [1 2 1; 2 4 2;1 2 1];
and if I call
chck_inv_PSF = inv(PSF);
this returns a matrix with values as infinity. But if I get the
inverse as a division by the identity matrix, i.e.
PSF_size =[3,3];
inv_PSF = eye(PSF_size(1), PSF_size(2))./PSF;
Then it will return a matrix with values in the diagonal.
16 0 0
0 4 0
0 0 16.

Which one is correct? Am I doing anything wrong?

Thanks in advance for all the help.

Dev

Subject: Inverse of a matrix

From: Miroslav Balda

Date: 24 Jun, 2008 04:21:02

Message: 2 of 3

Dev <gunadp@yahoo.com> wrote in message
<be763f10-6c53-46bc-8eec-624e52024a89@i18g2000prn.googlegroups.com>...
> Hi All,
>
> I want to get the inverse of a matrix. For example, if the
matrix is
> PSF =(1/16)* [1 2 1; 2 4 2;1 2 1];
> and if I call
> chck_inv_PSF = inv(PSF);
> this returns a matrix with values as infinity. But if I
get the
> inverse as a division by the identity matrix, i.e.
> PSF_size =[3,3];
> inv_PSF = eye(PSF_size(1), PSF_size(2))./PSF;
> Then it will return a matrix with values in the diagonal.
> 16 0 0
> 0 4 0
> 0 0 16.
>
> Which one is correct? Am I doing anything wrong?
>
> Thanks in advance for all the help.
>
> Dev

Hi Dev

The first result is OK. Why? Your matrix is singular, which
has no finite inverse. Its rang is one, because the first
and last rows are the same and second row is only doubled
first row.
Why your second attempt gave finite results? The operation
you used was not an inverse, but only an array division
(term by term).

Mira

Subject: Inverse of a matrix

From: John D'Errico

Date: 24 Jun, 2008 08:14:05

Message: 3 of 3

Dev <gunadp@yahoo.com> wrote in message <be763f10-6c53-46bc-8eec-
624e52024a89@i18g2000prn.googlegroups.com>...
> Hi All,
>
> I want to get the inverse of a matrix. For example, if the matrix is
> PSF =(1/16)* [1 2 1; 2 4 2;1 2 1];
> and if I call
> chck_inv_PSF = inv(PSF);
> this returns a matrix with values as infinity. But if I get the
> inverse as a division by the identity matrix, i.e.
> PSF_size =[3,3];
> inv_PSF = eye(PSF_size(1), PSF_size(2))./PSF;
> Then it will return a matrix with values in the diagonal.
> 16 0 0
> 0 4 0
> 0 0 16.
>
> Which one is correct? Am I doing anything wrong?

rank will show your matrix to be singular.

You cannot form a finite inverse for a
singular matrix.

You should not be using inv in the first
place. There are far better choices almost
always. Just because the formula in your
book shows a matrix inverse, it is usually
incorrect to implement that formula as
written with an inverse. Instead, use
either matlab's backslash operator, or
the pinv function.

John

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.
Related Topics