How to create multiple matrices with multiple variable?
1 次查看(过去 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!