Make Sequence Function go Diagonal

조회 수: 1 (최근 30일)
Ainars Cernavskis
Ainars Cernavskis 2021년 7월 19일
댓글: Rena Berman 2023년 11월 27일
Hi ,how would i make this function go diagonal?,any help would be great
n = input ('sequence_matrix_');
fibb=[1,3:n];
for i=3:n
fibb(i)=fibb(i-1)*3+(i)-2;
end
fibb
  댓글 수: 2
Sam Chak
Sam Chak 2023년 11월 23일
The original question may be beneficial for people who wish to learn how to create a diagonal matrix.
Rena Berman
Rena Berman 2023년 11월 27일
(Answers Dev) Restored edit

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

채택된 답변

Sameer Pujari
Sameer Pujari 2021년 7월 19일
Just do this small change
n = input ('sequence_matrix_');
fibb=[1,3:n];
for i=3:n
fibb(i)=fibb(i-1)*3+(i)-2;
end
diag(fibb)
  댓글 수: 1
Ainars Cernavskis
Ainars Cernavskis 2021년 7월 19일
o it was that simple , thank you .

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

추가 답변 (1개)

Walter Roberson
Walter Roberson 2021년 7월 19일
n = input ('sequence_matrix_');
fibb = diag([1,3:n]);
for i=3:n
fibb(i,i) = fibb(i-1,i-1)*3+(i)-2;
end
fibb

카테고리

Help CenterFile Exchange에서 Time Series Objects에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by