MATLAB Answers

How to became my Tridiagonal matrix

4 views (last 30 days)
B=[
16, 2 , 3, 13;...
5 , 11, 10, 8;...
9 , 7 , 6, 12;...
4, 14, 15, 1]
How to became my Tridiagonal matrix
16 0 0 0
5 2 0 0
9 11 3 0
4 7 10 13
0 14 6 8
0 0 15 12
0 0 0 1

  1 Comment

Dana
Dana on 7 Jul 2020
If you want help. you should provide a much more detailed question. I have no idea what you're asking here.

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 8 Jul 2020
full(spdiags(B',0:-1:-3,7,4))

  0 Comments

Sign in to comment.

More Answers (2)

KSSV
KSSV on 8 Jul 2020
Read about diag.
iwant = diag(1:5)+diag(1:4,-1)+diag(1:4,1) ;

  0 Comments

Sign in to comment.


madhan ravi
madhan ravi on 8 Jul 2020
[m, n] = size(B);
ix = (1 : 2*m : n*2*m) + (0 : n - 1).';
Wanted = zeros(2*m - 1 , n);
Wanted(ix) = B

  0 Comments

Sign in to comment.

Tags

Products


Release

R2019b