I have a vector that I know will consist of the values 100, 200 and 400. The values will not be mixed up but be it order, for example
target = [100 100 100 100 200 200 400 400 400];
I want to split this vector up into three vectors, each vector containing all the values of that kind.
A = [100 100 100 100];
B = [200 200];
C = [400 400 400];
The length of target will change from time to time and so will the proportion of 100, 200 and 400.
How can I make this split in an easy way?
My own solution looks like this but I was thinking that there is another way that requires less code.
columns = size(target, 2);
A = [];
B = [];
C = [];
% Splitting target into groups
for j = 1:columns
if target(1, j) == 100
A = [A, 100];
elseif target(1, j) == 200
B = [B, 200];
elseif target(1,j) == 400
C = [C, 400];
end
end
