MATLAB: How to Group strings

groupingMATLAB

Hi Everyone,
How can I group strings based on their values?
Example: a=[1 2 3 4]; b=[0 5 3 5]; c=[9 4 7 7]; d=[9 7 3 1];
I want to make a group of the strings that have value of 3 in their 3rd column. Those will be a,b and d.
Can 1 string perticipate in more than one groups? For example Group 1 is the already mentioned one, and Group 2 would be made of the strings that have value of 9 in the 1st column. Those will be strings c and d.
Cheers, Vihar

Best Answer

Storing the data in different variables is not efficient. This would be much faster and easier to expand:
Data = [1 2 3 4; ...
0 5 3 5; ...
9 4 7 7; ...
9 7 3 1];
Group{1} = find(Data(:, 3) == 3);
Group{2} = find(Data(:, 1) == 9);
And even the outputs should not be numbered, but collected in a cell array.