MATLAB: Accessing cell array via factor/index

cell arrays

Hello,
i have a cell array of 458×3 cells. The first two array columns are numeric, while the last one consists of 4 different strings ('fs','pre','sv','to'). I need to extract the data based on the strings. So, I want to create different groups out of it and make a boxplot for comparison later.
My try was:
data_fs=data{data{:,3} == 'fs',1}
(I access all rows in column 1 and meanwhile I compare the 3rd array column with 'fs')
Well, that obviously doesn't work. Any help is appreciated!
Sorry, for the trivial question. Quite new to MatLab.
thanks!
edit: It is working with boxplot(data,group). But I am still interested in how I can extract the appropriate data sets.

Best Answer

You're pretty close in your attempt; it's tricky with the cell indexing and without using strcmp. How about trying this
% array of all strings used as grouping classes
groupLabels = {'fs','pre','sv','to'};
% anonymous function for id'ing rows
f = @(s)data(strcmp(s,data(:,3)),:);
% get the groups
groups = cellfun(f,groupLabels,'UniformOutput',false);