matlab simple for loop -


I have 200 rows of data and I am trying to remove specific numbers from column 3 which is 1, 2 , 3, or 4, in column 1 (randomly duplicated).

I associated those numbers with column 1 in column 1

  E = C (C (:, 1) == 1, [3]);   

So I have assumed that I can remove all those 2 related to 1 then use 3 to 3 and 4 for i = 1

  4; E = C (C (:, 1) == I, [3]); Finally   

But I have all the data related to all 4 of this column 1. If I change it in 1: 3 then I get data related to 3S. I tried to write it for for I = [1,2,3,4] , but then in column 1, get the number from column 3 related to column 3.

I'm sure this is a simple error, but any help would be greatly appreciated thanks.

The problem is that you are overwriting the value of e Through time, so in the end you just left with the last walk.

If you are not guaranteed to have the same number of results each time through the loop (for example, the different numbers are 1 s and 2 < / Code> s), you can use a cell array to store the output:

  i = 1: 4; E {i} = c (c (:, 1) == i, [3]); To reach the result of the first repetition of the end   

loop ( i == 1 ), use e {1} (And for other values).

The above approach will allow you to access different results from each visit if you later decide that you want a matrix with results from all these iterations, then you

  can use cell2mat (E)   

for an array of all values.

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -