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

조회 수: 1 (최근 30일)
absadgs
absadgs 2020년 2월 23일
편집: Guillaume 2020년 2월 23일
The matrix is 400 by 400 and i need a -1 2 -1 pattern starting with 2. Like this:

채택된 답변

Guillaume
Guillaume 2020년 2월 23일
편집: Guillaume 2020년 2월 23일
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)])

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by