Reputation: 178
I successfully created a moving window of n=85 for my data and put the windows in a cell array:
n = 37886;
cell_array=cell(n,1);
a = 1:n;
for T=1:n-84
M=a(T:T+84);
tmpstruct=struct('M',M);
cell_array{T}=tmpstruct;
end
However, I need to transpose M, which is the data of window values located within the structure within the cell array. That is, instead of the vector of window values being 1x85, I want them to be 85x1.
I've attempted transposing with this:
cell_array = cellfun(@transpose,cell_array,'UniformOutput',false);
But this code doesn't work for me.
Any feedback on how to transpose my windows will be greatly appreciated. I need to transpose 252 cell arrays, so doing this manually is out of the question.
Upvotes: 0
Views: 1985
Reputation: 23675
If I clearly understood, what about:
n = 37886;
cell_array=cell(n,1);
a = 1:n;
for T=1:n-84
M=a(T:T+84);
tmpstruct=struct('M',M'); % Modified line to transpose windows!
cell_array{T}=tmpstruct;
end
If you prefer named functions:
n = 37886;
cell_array=cell(n,1);
a = 1:n;
for T=1:n-84
M=a(T:T+84);
tmpstruct=struct('M',transpose(M)); % Modified line to transpose windows!
cell_array{T}=tmpstruct;
end
Upvotes: 2