How to generate a normal matrix?

조회 수: 10 (최근 30일)
Omar B.
Omar B. 2021년 3월 4일
댓글: Omar B. 2021년 3월 5일
How to generate the following matrix in MATLAB? where α is real number, and n is odd number.

채택된 답변

KALYAN ACHARJYA
KALYAN ACHARJYA 2021년 3월 4일
편집: KALYAN ACHARJYA 2021년 3월 4일
You can do this in many ways, one way is as follows
Hope, for the last corner mat(1,:)= ....element, you can manipulate:
Sufficient Hints:
alpha=.....;
n=....; % Square Matrix
diag_mat=diag(alpha*ones(1,n));
pattern_data=triu(ones(n),-1).*tril(ones(n),-1);
Add those two matrices
result=...

추가 답변 (1개)

Bjorn Gustavsson
Bjorn Gustavsson 2021년 3월 4일
Have a look at the help and documentation of the diag-function. This question indicates that you're very new to matlab, so you might get up to speed faster if you look through the matlab-onramp material. One of the main skills to learn is to browse efficiently through the help. You should also be able to use the lookfor function to find starting-points for your help-search.
HTH
  댓글 수: 3
Bjorn Gustavsson
Bjorn Gustavsson 2021년 3월 4일
Well this is just "2/3rds" of a tri-diagonal matrix, so then you should be set?
A = diag(alpha*ones(n,1),0) + diag(ones(n-1,1),-1);
I typically forgets if I need +1 or -1 for the sub/sup-diagonals and have to check - but checking is a good fraction of good programming practice...
Omar B.
Omar B. 2021년 3월 5일
Thank you. I did it.

댓글을 달려면 로그인하십시오.

카테고리

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