Friday, 15 April 2011

Eliminating part of arrays in matlab -


Assume that we have a 100 * 4 array.

We also have a 100 * 1 array, say 1 and 0, assuming that N1 is.

We want to create an array * 4 from the array 100 * 4, where we include only those columns for which the second array is 1.

One way to do this is through a double for the loop. Is there an easier way?

Then, we have

  A = [332 44 33 22 33 55 33 211 ..... [823 44 12 98 1] 23 32 9 11. ... .... .... ....   

and

  b = [0 0 0 0 0 0 ...]   

and we want

  c = [[332 22 ... [823 98 ... ... ... .]    

You should use:

  C = A (:, B == 1);    

No comments:

Post a Comment