How to create multiple matrices with multiple variable?
5 ビュー (過去 30 日間)
古いコメントを表示
provided x=1:100
How to create 100 matrices (all must be having pattern of [x 0 0; 0 x 0; 0 0 x]) at the same time without typing it one by one?
P.S. : I meet this problem when studying multiple variable linear regression
0 件のコメント
回答 (1 件)
Chunru
2022 年 1 月 21 日
n = 5; % 100
% each slice of a is a matrix you want to produce:
a = eye(3).*reshape(1:n, [1 1 n])
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!