Since this matrix has some pattern to it, must be a nicer way to write it? Thanks

댓글 수: 1

dpb
dpb 2016년 5월 1일
편집: dpb 2016년 5월 1일
Edit it to align it so it's clearly legible what the pattern is--too hard to keep columns straight as is, sorry...but using diag and friends may be of some help.

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

 채택된 답변

Roger Stafford
Roger Stafford 2016년 5월 1일
편집: Roger Stafford 2016년 5월 1일

0 개 추천

k = 1e6*(diag(s(1:22),1)+diag(s(1:22),-1)+...
diag(-[s(1:22),0]-[0,s(1:22)]));
I am assuming s is a row vector here. Make the obvious change if it is a column vector.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

질문:

2016년 5월 1일

댓글:

2016년 5월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by