Make Sequence Function go Diagonal

1 次查看(过去 30 天)
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.

请先登录,再进行评论。

采纳的回答

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 个)

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 中查找有关 Operating on Diagonal Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by