
Summing specific columns in a 2D wave
Peeyush Khare
Hi,
I have a 2D wave with 23 rows and 19 columns: datawave (23,19)
Now, I want to create a new 2D wave newdatawave(23,11) which will have the first 10 columns from datawave as is. For the 11th column, I want the horizontal sum of 11-19 columns from datawave.
I am trying MatrixOp to accomplish this via a 1-2 liner code but couldn't get the right syntax.
Kindly help on how to accomplish this task.
Thanks a lot in advance!
This is how I would do it:
May 1, 2020 at 01:56 pm - Permalink
In reply to This is how I would do it: … by sjr51
That worked perfectly, sjr51! Thanks for teaching!
May 1, 2020 at 02:08 pm - Permalink
You can save one line using:
MatrixOP/O bb = catcols(bb, sumrows(bb))
EDIT:
ok, turns out you could even do a one-liner (although I wouldn't recommend that):
MatrixOP/O bb = catcols(redimension(aa, 23, 10), sumrows(redimension(aa, 23, 10)))
Still, MatrixOP is awesome!
May 2, 2020 at 10:27 am - Permalink