How do i generate 10 random matrix and store them?

1 回表示 (過去 30 日間)
yang-En Hsiao
yang-En Hsiao 2019 年 11 月 5 日
回答済み: Bhaskar R 2019 年 11 月 5 日
I want to generate 10 random matrix ,H_AB ,and store them in to H_AB_store ,here is my original code
At=7;
Br=2;
rw=10
H_AB_store=zeros(Br*rw,At*rw)
for i=1:rw
H_AB = sqrt(1/2)*[randn(Br,At) + j*randn(Br,At)];
H_AB_store(Br*i,At*i)=H_AB
end
However,the window always told me this error
Assignment has more non-singleton rhs dimensions than non-singleton subscripts
Error in unit_channel (line 7)
H_AB_store(Br*i,At*i)=H_AB
How do i modify this error?

採用された回答

Bhaskar R
Bhaskar R 2019 年 11 月 5 日
You can perform this using multi dimentional(here say rw = 10) array or cell array(prefered when random matrix size not consistant each loop)
All 10 random matrices have same size so multi dimentional array usage is recommended
At=7;
Br=2;
rw=10;
H_AB_store=zeros(Br, At, rw);
for i=1:rw
H_AB_store(:, :, i) = sqrt(1/2)*[randn(Br,At) + i*randn(Br,At)];
end
You can access each matrix indexing as H_AB_store(:, :, 1), H_AB_store(:, :, 2),.. H_AB_store(:, :, 10) for random matrices

その他の回答 (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