I have an array of cells of arrays of cells ...
data = {1x16} {1x16} {1x16}
and I'm trying to get the first value from each of the cells. However when i do
data{:}(1)
I get an error
Bad cell reference operation.
First of all, is there a good reason why I am not allowed to do this? And secondly, is there a way around this?
Hooray! Ben
For an array of cells 1D-
1D
first_vals = arrayfun(@(n) data{n}(1),1:numel(data))
This should work in the general case -
first_vals = reshape(arrayfun(@(n) data{n}(1),1:numel(data)),size(data))
I would prefer to do this using a simple loop:
For example, this will work:
data = [{[1:16]}; {[17:32]}; {[33:48]}]; b= [] for i=1:length(data) b = [b data{i,1}(1)]; end