How to store vectors of unequal sizes, created by a for loop in a cell?

2 ビュー (過去 30 日間)
Brittny Freeman
Brittny Freeman 2019 年 5 月 27 日
コメント済み: Star Strider 2019 年 5 月 27 日
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

採用された回答

Star Strider
Star Strider 2019 年 5 月 27 日
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 件のコメント
Brittny Freeman
Brittny Freeman 2019 年 5 月 27 日
Thanks for getting back to me Star, I've yet to pose a question that you couldn't answer!
I was able to get it to work, just had to make one small adjustment as shown below:
SK_BL_Cell{k} = SK_BL;
F_out_BL_Cell{k} = F_out_BL;
Thresh_BL_Cell{k} = Thresh_BL;
The answer was so easy, don't know why I didn't see it beforehand.
Star Strider
Star Strider 2019 年 5 月 27 日
My pleasure.
If my Answer helped you solve your problem, please Accept it!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by