Changing array dimension


SteveMyres

Recommended Posts

You can't do this in one shot, but you can do it in 5 or 6 shots instead of 30 by using transpose. Lets assume x is your 1x30 array and y is your 5x6 (I'm going to assume also that 1 and 5 are your columns, and 30 and 6 are rows):

for (var i = 0, i < 6, i++)

y = transpose(x[i*5, i*5+4],1)

endfor

To do it even faster, do it the other way, but of course that is also changing the ordering:

for (var i = 0, i < 5, i++)

y[] = x[i*6, i*5+5]

endfor

Which you use depends on whether the 1x30 is grouped by rows or columns when it becomes 5x6. The best way to see this work is to set x = seqadd(1,1,30) which makes x = {1,2,3,...} and then look at the result of both.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.