Storage many same dimension matrixes to one matrix

1 Ansicht (letzte 30 Tage)
yiying peng
yiying peng am 15 Jun. 2022
Kommentiert: yiying peng am 15 Jun. 2022
if x1 x2 x3 all 4x4 matrix
i want storage them easy to k=[x1 x2 x3] and i have k matrix 4x12
but when n is larger to 100000
for i = 1:100000
eval( ['x', num2str(i), '=ifft2(randi([0 15],4,4));'] );
end
i use above code to generate 100000 matrixs all matrix are in 4x4 dimension
how can i stoage x1 x2 ... x100000 to a matrix k,k matrix dimesion is 4x400000
any method to do
k=[x1 x2 x3 x4 x5 ........ x100000]

Akzeptierte Antwort

Chunru
Chunru am 15 Jun. 2022
Try to avoid eval. Use N-D array or cell array instead.
n=10; %100000
x = zeros(4, 4, n);
for i = 1:n
x(:,:,i) = ifft2(randi([0 15], 4, 4));
end

Weitere Antworten (0)

Kategorien

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

Community Treasure Hunt

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

Start Hunting!

Translated by