
Make Sequence Function go Diagonal
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Ainars Cernavskis
il 19 Lug 2021
Commentato: Rena Berman
il 27 Nov 2023
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 Commenti
Sam Chak
il 23 Nov 2023
The original question may be beneficial for people who wish to learn how to create a diagonal matrix.

Risposta accettata
Sameer Pujari
il 19 Lug 2021
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)
Più risposte (1)
Walter Roberson
il 19 Lug 2021
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
0 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!