How do i generate 10 random matrix and store them?

1 visualización (últimos 30 días)
yang-En Hsiao
yang-En Hsiao el 5 de Nov. de 2019
Respondida: Bhaskar R el 5 de Nov. de 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?

Respuesta aceptada

Bhaskar R
Bhaskar R el 5 de Nov. de 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

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by