comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Matlab Syntax
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Matlab Syntax [message #37030 is a reply to message #37029] Thu, 20 November 2003 13:44 Go to previous messageGo to previous message
James Kuyper is currently offline  James Kuyper
Messages: 425
Registered: March 2000
Senior Member
David Fanning wrote:
>
> Folks,
>
> I need more Matlab help. Here is the line I am
> struggling with:
>
> invAI = inv(A + gamma * diag(ones(1,N)));
>
> A is a matrix and gamma is the scalar 1.0.
>
> Here is the output from Matlab when I print
> A and invAI:
>
> A =
> 8 -5 1 1 -5
> -5 8 -5 1 1
> 1 -5 8 -5 1
> 1 1 -5 8 -5
> -5 1 1 -5 8
>
> invAI =
>
> 0.3158 0.2105 0.1316 0.1316 0.2105
> 0.2105 0.3158 0.2105 0.1316 0.1316
> 0.1316 0.2105 0.3158 0.2105 0.1316
> 0.1316 0.1316 0.2105 0.3158 0.2105
> 0.2105 0.1316 0.1316 0.2105 0.3158
>
> I have the matrix A in my IDL session:
>
> IDL> print, array
> 8.00000 -5.00000 1.00000 1.00000 -5.00000
> -5.00000 8.00000 -5.00000 1.00000 1.00000
> 1.00000 -5.00000 8.00000 -5.00000 1.00000
> 1.00000 1.00000 -5.00000 8.00000 -5.00000
> -5.00000 1.00000 1.00000 -5.00000 8.00000
>
> But I get the wrong answers when I invert. Here is
> my translation of the Matlab inverse line:
>
> invARRAY = Invert((ARRAY + gamma) ## Diag_Matrix(Replicate(1,npts)) )

I know nothing special about Matlab, but the matlab equation seems
pretty clear. I assume that inv() and Invert() do the same thing, and
that diag() and Diag_Matrix() serve the same purpose, and that ones(1,N)
does the same thing as Replicate(1,npts). If so, then unless I'm
massively confused (which is possible), shouldn't that be:

invARRAY = Invert((ARRAY + gamma * Diag_Matrix(Replicate(1,npts))) )
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Byte Swapping
Next Topic: PostScript output from iTools

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sun Oct 12 10:29:52 PDT 2025

Total time taken to generate the page: 2.40250 seconds