03-16-2012 02:00 PM - edited 03-16-2012 02:02 PM
Hi,
I'm working with a large one dimensional column array. I'm trying to do the following
for i=1:size(A)/2
B(i,: ) =A(1+(i-1)*2:i*2)
So, for example if
A=
0
1
2
3
4
5
6
7
then
B=
0 1
2 3
4 5
6 7
My approach was to use an array subset block inside the for loop to select a number of elements but I'm not sure how to transpose the selected elements into a new row to create the new array B. Is there a more straightforward approach?
Thanks,
Mike
Solved! Go to Solution.
03-16-2012 02:16 PM - edited 03-16-2012 02:21 PM
try experimenting with the reshape array feeding it your input array and re-sizing it to output a 2d aray. It is much faster than using a For loop becuase the data never gets moved and LV just changes the array dimensions and updates the stride.
Ben
03-17-2012 02:27 PM
Thanks, I tried it with reshape and its much easier.