how can i create a 400 by 400 matrix with a pattern?

1 vue (au cours des 30 derniers jours)
absadgs
absadgs le 23 Fév 2020
Modifié(e) : Guillaume le 23 Fév 2020
The matrix is 400 by 400 and i need a -1 2 -1 pattern starting with 2. Like this:

Réponse acceptée

Guillaume
Guillaume le 23 Fév 2020
Modifié(e) : Guillaume le 23 Fév 2020
full(gallery('tridiag', 400))
If the subdiagonal, diagonal and superdiagonal were anything other than -1, 2, 1, for example: 1, 2, 3 respectively:
fulll(gallery('tridiag', 400, 1, 2, 3))
Another way:
toeplitz([2, -1, repelem(0, 398)])

Plus de réponses (0)

Catégories

En savoir plus sur Matrices and Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by