how to create 200 random matrices using loop..
古いコメントを表示
Hi..I want to create separate 200 random matrices of size 32*32 , and each to be multiplied with my input matrix..whether any looping is possible here ..please help ..
thank in advance
採用された回答
その他の回答 (1 件)
Matz Johansson Bergström
2014 年 8 月 23 日
I have not tried it but something like this:
n=200;
tmp = rand(32,32,n);
and then to multiply each matrix
for i=1:n
in = in*tmp(:,:,i)
end
2 件のコメント
Abhishek sadasivan
2014 年 8 月 23 日
Matz Johansson Bergström
2014 年 8 月 23 日
編集済み: Matz Johansson Bergström
2014 年 8 月 23 日
I would argue that this is possible and very simple using a 3D matrix. The data is stored in another way, that's all and very efficient, because Matlab is made for matrices. For small matrices this does not really matter, but for larger ones it might make a difference.
My suggestion stacks the matrices into a 3d matrix and you can simply pick out the matrices like you would any other data structure.
Also, to sum all the matrices, you just have to write
sums = squeeze(sum(sum(tmp)))
This gives you the sum of all the elements in each matrix as a vector. Sums(i) contains the sum of matrix i.
カテゴリ
ヘルプ センター および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!