How do i generate 10 random matrix and store them?

1 Ansicht (letzte 30 Tage)
yang-En Hsiao
yang-En Hsiao am 5 Nov. 2019
Beantwortet: Bhaskar R am 5 Nov. 2019
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?

Akzeptierte Antwort

Bhaskar R
Bhaskar R am 5 Nov. 2019
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

Weitere Antworten (0)

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by