How to store vectors of unequal sizes, created by a for loop in a cell?
2 views (last 30 days)
Show older comments
Brittny Freeman
on 27 May 2019
Commented: Star Strider
on 27 May 2019
Hello all,
I am trying to use the pkurtosis function within a for loop on my Pitch_BL 1-D time sereis vector as shown below. However, in the output, SK_BL is a different length for each iteration of the loop, and thus makes it impossible to store all of the outputs of SK_BL into a single matrix.
I am attempting to get around this by having the for loop run the pkurtosis function 25 different times, and for each time, store the output variables in a cell, SK_BL_Cell(:,k), thus allowing vectors of unequal lengths to be concatenated together.
Unfortunatley, my code is giving me an error,"Index in position 2 exceeds array bounds (must not exceed 1)", and I was wondering if someone could help.
Thanks in advance.
for k = 1:25
[SK_BL, F_out_BL, Thresh_BL] = pkurtosis(Pitch_BL(:,k),Fs,wc_BL(k,:),'ConfidenceLevel',0.95);
SK_BL_Cell(:,k) = num2cell(SK_BL(:,k));
F_out_BL_Cell(:,k) =num2cell(F_out_BL(:,k));
Thresh_BL_Cell(:,k) = num2cell(Thresh_BL(k,:));
end
0 Comments
Accepted Answer
Star Strider
on 27 May 2019
I would just do something like this:
SK_BL_Cell{k} = SK_BL(:,k);
F_out_BL_Cell{k} = F_out_BL(:,k);
Thresh_BL_Cell{k} = Thresh_BL(k,:);
2 Comments
Star Strider
on 27 May 2019
My pleasure.
If my Answer helped you solve your problem, please Accept it!
More Answers (0)
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!