0

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.

1 Answer 1

2

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
Sign up to request clarification or add additional context in comments.

6 Comments

The code you copied is the code I am using to put my data in windows of size 85. The windows are in a structure within a cell array; I need to transpose the windows. Let me know if you need more clarification.
You missed a little ' sign inside my code that will transpose your windows. Try to run it and tell me if this is what you want.
' is not transpose; it is conjugate transpose
The OP asked this: "That is, instead of the vector of window values being 1x85, I want them to be 85x1.", and my code does -exactly- what he asks for.
@TommasoBelluzzo my code does -exactly- what he asks for except if a is complex (I assume a = 1:n in OP's code is just an example). To just transpose, use .'
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.