フィルターのクリア

As I'm loading data into a cell array through a loop, I end up with a matrix that is double the size of what it should be.

1 回表示 (過去 30 日間)
I am loading data into graph1 cell array with two loops. The S matrix is 1x410, but after I run the code, graph1 ends up being 1x820, and the data in the later half of the matrix 411:820 is mostly of zeros. Am I doing something wrong, or can I just ignore the later half? Thanks in advance!
Here is my code:
for i=1:size(tph,1)
strt = floor(tph(i,1)*fs);
lst = floor(tph(i,2)*fs);
filt = chronux.ct.rmlinesmovingwinc(X(strt:lst,channel), [win/fs,step/fs], 20, params, .3, 'n', [59 60 100 119 120 121 140 180]);
[S,f] = chronux.ct.mtspectrumc(filt,params);
for j=1:size(S,1)
graph1{j}(i) = S(j);
end
end
  2 件のコメント
Stephen23
Stephen23 2022 年 7 月 16 日
編集済み: Stephen23 2022 年 7 月 16 日
@Selena: do you preallocate GRAPH1 before the loop? Are the sizes of S the same on every i iteration?
"graph1 ends up being 1x820, and the data in the later half of the matrix 411:820 is mostly of zeros."
This explanation does not match your code, which indicates that GRAPH1 is a cell array or table or similar.
Selena
Selena 2022 年 7 月 16 日
Ooooh I see, S is not the same size every iteration. Thank you for your help!

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by