How do I take square roots of certain entries of a tridiagonal matrix?
2 views (last 30 days)
Show older comments
So I have a 50 by 50 tridiagonal matrix. The entries along the main diagonal are 0 and the entries above and below are -square root (k(N-k) where N is 50 and k is an integer from 1 to 50. I am completely new to matlab and have no programming experience. Can someone please help?
0 Comments
Accepted Answer
Guillaume
on 3 Mar 2015
N = 50;
v = 1:N-1; %a 50x50 matrix only have 49 elements above and below diagonal
m = full(gallery('tridiag', -sqrt(v.*(N-v)), zeros(1, N), -sqrt(v.*(N-v))))
3 Comments
More Answers (0)
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!