Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
JoeNiner
 
Posts: n/a
Default How do I get the diagonal of a matrix from excel?

excel 2003 or 2007 beta 2

How can I get the diagonal of a matrix returned as a single column vector?
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Max
 
Posts: n/a
Default How do I get the diagonal of a matrix from excel?

"JoeNiner" wrote:
How can I get the diagonal of a matrix returned as a single column vector?


One try ..

Assuming a 4 x 4 grid in B2:E5 (top left cell is B2)

Perhaps this expression:
=OFFSET(B2,ROW(INDIRECT("1:4"))-1,ROW(INDIRECT("1:4"))-1)

Or maybe this expression below,
array-entered into a 4 cell columnar range, say into B20:B23 :
=INDEX(B2:E5,ROW(INDIRECT("1:4")),ROW(INDIRECT("1: 4")))

--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Biff
 
Posts: n/a
Default How do I get the diagonal of a matrix from excel?

=INDEX(B2:E2,,ROWS($1:1))

Copied down

Biff

"Max" wrote in message
...
"JoeNiner" wrote:
How can I get the diagonal of a matrix returned as a single column
vector?


One try ..

Assuming a 4 x 4 grid in B2:E5 (top left cell is B2)

Perhaps this expression:
=OFFSET(B2,ROW(INDIRECT("1:4"))-1,ROW(INDIRECT("1:4"))-1)

Or maybe this expression below,
array-entered into a 4 cell columnar range, say into B20:B23 :
=INDEX(B2:E5,ROW(INDIRECT("1:4")),ROW(INDIRECT("1: 4")))

--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---



  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Harlan Grove
 
Posts: n/a
Default How do I get the diagonal of a matrix from excel?

Max wrote...
"JoeNiner" wrote:
How can I get the diagonal of a matrix returned as a single column vector?


One try ..

Assuming a 4 x 4 grid in B2:E5 (top left cell is B2)

Perhaps this expression:
=OFFSET(B2,ROW(INDIRECT("1:4"))-1,ROW(INDIRECT("1:4"))-1)

....

FWIW, can't use the expression above as a term in an array formula.
It's need to be

N(OFFSET(B2,ROW(INDIRECT("1:4"))-1,ROW(INDIRECT("1:4"))-1))

This can be done without volatile functions. As a column vector,

=MMULT((ROW(M)-MIN(ROW(M))=COLUMN(M)-MIN(COLUMN(M)))*M,
TRANSPOSE(COLUMN(M))^0)

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Max
 
Posts: n/a
Default How do I get the diagonal of a matrix from excel?

"Harlan Grove" wrote:
FWIW, can't use the expression above as a term in an array formula.
It's need to be
N(OFFSET(B2,ROW(INDIRECT("1:4"))-1,ROW(INDIRECT("1:4"))-1))


Thanks for correction, Harlan.

This can be done without volatile functions. As a column vector,
=MMULT((ROW(M)-MIN(ROW(M))=COLUMN(M)-MIN(COLUMN(M)))*M,
TRANSPOSE(COLUMN(M))^0)


I suppose M is a defined range referring to the matrix,
eg to the 4 x 4 grid in B2:E5

Does the N(..) need to be likewise applied here ?
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---


  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Harlan Grove
 
Posts: n/a
Default How do I get the diagonal of a matrix from excel?

Max wrote...
"Harlan Grove" wrote:
FWIW, can't use the expression above as a term in an array formula.
It's need to be
N(OFFSET(B2,ROW(INDIRECT("1:4"))-1,ROW(INDIRECT("1:4"))-1))


Thanks for correction, Harlan.


Wasn't a correction per se. Your formula works when entered as an array
formula into 1-column by 4-row ranges, but

=SUMPRODUCT(OFFSET(B2,ROW(INDIRECT("1:4"))-1,ROW(INDIRECT("1:4"))-1))

returns #VALUE! errors while

=SUMPRODUCT(N(OFFSET(B2,ROW(INDIRECT("1:4"))-1,ROW(INDIRECT("1:4"))-1)))

returns expected results.

This can be done without volatile functions. As a column vector,
=MMULT((ROW(M)-MIN(ROW(M))=COLUMN(M)-MIN(COLUMN(M)))*M,
TRANSPOSE(COLUMN(M))^0)


I suppose M is a defined range referring to the matrix,
eg to the 4 x 4 grid in B2:E5


Correct.

Does the N(..) need to be likewise applied here ?


Why don't you test it? Hint, try the array formula

=SUM(MMULT((ROW(M)-MIN(ROW(M))=COLUMN(M)-MIN(COLUMN(M)))*M,
TRANSPOSE(COLUMN(M))^0))

It has to be an array formula because both MMULT and TRANSPOSE require
array formula entry.

  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Max
 
Posts: n/a
Default How do I get the diagonal of a matrix from excel?

Thanks for the clarifications, Harlan.
Much appreciated.
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
unhide menu bar in excel - just disappeared Sean Setting up and Configuration of Excel 12 April 4th 23 10:19 AM
Sharing read-write Excel 2003 files ttt8262 Excel Discussion (Misc queries) 0 April 1st 06 09:39 PM
how do i create a training matrix in excel goldhead Excel Discussion (Misc queries) 3 January 24th 06 01:53 PM
Difference in number of Excel NewsGroups Hari Prasadh Excel Discussion (Misc queries) 1 January 25th 05 11:32 AM
How do I print a file holder label from Excel to a dox matrix pri. Al_R Excel Discussion (Misc queries) 0 January 5th 05 10:05 PM


All times are GMT +1. The time now is 04:54 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"