フィルターのクリア

create two matrices from a larger matrix

1 回表示 (過去 30 日間)
tony karamp
tony karamp 2013 年 3 月 28 日
hi,
so I have this matrix harmonics [40x99226] and I want to create two matrices from the original, called harmA and harmB. harmA will have the rows 1,3,5...39 while harmB will get the rest 2,4,6...40. The new matrices will still carry all the 99226 samples that belong to each row. This is what I have so far, but it's not doing the trick.
Thank you for taking the time, I appreciate it!

採用された回答

Wayne King
Wayne King 2013 年 3 月 28 日
編集済み: Wayne King 2013 年 3 月 28 日
Just do:
X = randn(40,99226);
harmA = X(1:2:end,:);
harmB = X(2:2:end,:);
MATLAB is generally really good at handling these types of matrix-vector operations without loops.

その他の回答 (1 件)

tony karamp
tony karamp 2013 年 3 月 28 日
omg... you are right!
I had tried
harmA = X(1:2:end);
harmB = X(2:2:end);
but didn't work.
I didn't think to add the other dimension.
Thanks a bunch

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by