From: Teresa on
I have a 18x18 cell matrix with each cell containing a 1000x1 column vector. I wish to copy the first 100 points of each cell into another cell matrix. My first intuition is to use newdata = old_data{:}(1:100,1) but I get a bad cell reference. Can I go about accessing this data without addressing each cell individually?

THANKS!
From: Oleg Komarov on
"Teresa " <tflax005(a)uottawa.ca> wrote in message <hm0qaj$81b$1(a)fred.mathworks.com>...
> I have a 18x18 cell matrix with each cell containing a 1000x1 column vector. I wish to copy the first 100 points of each cell into another cell matrix. My first intuition is to use newdata = old_data{:}(1:100,1) but I get a bad cell reference. Can I go about accessing this data without addressing each cell individually?
>
> THANKS!
help cellfun

example:
newCellArray = cellfun(@(x) x(1:100), yourCellArray,'un',0);

Oleg
 | 
Pages: 1
Prev: Bug in datevec
Next: Matlab Engine issues