how to Assemble this matrix

4 views (last 30 days)
amar
amar on 28 Jan 2016
Commented: Rena Berman on 24 Jan 2017
  3 Comments
Rena Berman
Rena Berman on 24 Jan 2017
(Answers dev) Restored question.

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 30 Jan 2016
n = 4; %for example
main_diagonal = [ [-4, repmat(-3,1,n-2), -4], repmat([-5, repmat(-4,1,n-2), -5], 1, 2), [-6, repmat(-5,1,n-2), -6] ];
N = length(main_diagonal);
m = diag(ones(1, N-4), -4) +
diag(ones(1, N-1), -1) +
diag(main_diagonal) +
diag(ones(1, N-1), 1) +
diag(ones(1, N-4), -4)

More Answers (0)

Categories

Find more on Operating on Diagonal Matrices in Help Center and File Exchange

Tags

No tags entered yet.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!