How to create a diagonal matrix that starts at (1,1)?
6 views (last 30 days)
Show older comments
Can someone help me?
How do I create a diagonal matrix of lambda, where lambda = 0.2? I would like the diagonal to start at (1,1).
Any help would be greatly appreciated.
3 Comments
Accepted Answer
Star Strider
on 21 Nov 2021
Without using repmat —
n = 4;
lambda = 0.2;
A = diag([0 ones(1,n)]*lambda)
,
0 Comments
More Answers (2)
Jan
on 21 Nov 2021
Maybe you mean:
n = 4;
lambda = 0.2;
A = eye(n) * lambda
% Or:
A = diag(repmat(lambda, 1, n))
0 Comments
See Also
Categories
Find more on Operating on Diagonal Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!