View previous topic :: View next topic |
Author |
Message |
dmcmillan
Joined: 04 Jul 2006 Posts: 22
|
Posted: Wed Jun 18, 2008 11:38 am Post subject: Use of SUM intrinsic array operator |
|
|
Hello,
I want to sum the columns of a 20 x 20 array. So far I have used:
SUM (myarray,DIM=1)
which gives back an 20 element array with the sum of each row. I want to select the rows individually.
Is there a way of doing this using the intrinsic SUM command?
I thought of storing it in a string then reading the string into an array which could then be accessed an element at a time. Looking for a more concise way of doing it.
Thanks
David McMillan |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Wed Jun 18, 2008 12:16 pm Post subject: |
|
|
You can do things like:
rsum = sum(myarray(irow,:))
for a given irow. |
|
Back to top |
|
|
dmcmillan
Joined: 04 Jul 2006 Posts: 22
|
Posted: Wed Jun 18, 2008 12:21 pm Post subject: |
|
|
Perfect - thanks for that.
DM |
|
Back to top |
|
|
|