How to write pentadigonal matix?
Mostrar comentarios más antiguos
How to generate the following penta diagonal matrix in matlab?

Respuesta aceptada
Más respuestas (1)
Bruno Luong
el 27 de Jul. de 2020
Editada: Bruno Luong
el 27 de Jul. de 2020
m = 4;
n = 3*m;
T = diag(ones(1,n-3),3);
A = T + T';
B = ones(3)-5*eye(3);
A = A + kron(eye(m),B)
1 comentario
Bruno Luong
el 27 de Jul. de 2020
Editada: Bruno Luong
el 27 de Jul. de 2020
If you insist on for loop
m = 4;
n = 3*m;
T = diag(ones(1,n-3),3);
A = T + T';
B = ones(3)-5*eye(3);
for k=1:m
i = (k-1)*3+(1:3);
A(i,i) = B;
end
A
Categorías
Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
