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 #37031 is a reply to message #37029] Thu, 20 November 2003 12:38 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
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)) )

Here is what I get:

0.185455 0.0581818 -0.0509091 -0.0509091 0.0581818
0.0581818 0.185455 0.0581818 -0.0509091 -0.0509091
-0.0509091 0.0581818 0.185455 0.0581818 -0.0509091
-0.0509091 -0.0509091 0.0581818 0.185455 0.0581818
0.0581818 -0.0509091 -0.0509091 0.0581818 0.185455

I'm pulling my hair out here! Can someone help?

Cheers,

David

--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
[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:49 PDT 2025

Total time taken to generate the page: 3.19977 seconds