I essentially want to pull the data from timepoints of interest and run the same functions for each "bout of data" even though these bouts are not always the same length. I understand a cell array will be helpful for this, but when I try to write for loop, the data is no longer in 'double' form to perform functions.
How can I convert to cell array but keep the data in 'double' type?
Example failure 1
% tot_dff: vector of data across time
%f_i & f_o : variables corresponding to time on and off for periods of interest in the data
for i=1:length(f_i);
dff{i} = num2cell(tot_dff(1,f_i(i):f_o(i)));
end
X = cellfun(@mean,dff);
Y = cellfun(@max,dff);
Error using sum
Invalid data type. First argument must be numeric or logical.
% In this case dff is 1×46 cell which each cell containing cells corresponding to each data point.
Example failure 2
for i =1:length(f_i);
dff{i} = {tot_dff(1,f_i(i):f_o(i))};
end
X=cellfun(@mean,dff);
Y=cellfun(@max,dff);
%in this case, dff is 1×46 cell array with each cell containing my list of numbers in [ ] . Still can't run the functions on it and get the same error.
When I create my cell array by hand
dff = {tot_dff(1:3),tot_dff(6:10)} …….. this works but will take me forever!
Thank you for your help!
Best Answer