Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
I want to make fibonacci series by this way, but there is some error in my code (I think in sum line), can someone point ?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
clear all
clc
n=20;
f=0;
for i=1:n
for i=1
f(i)=0;
end
for i=2
f(i)=1;
end
f(i:n)=sum(f);
end
f
![75573791_399777687595206_948524204263735296_n.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/248901/75573791_399777687595206_948524204263735296_n.png)
![74917391_506001480322486_8562696738337456128_n.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/248902/74917391_506001480322486_8562696738337456128_n.png)
1 Kommentar
KALYAN ACHARJYA
am 18 Nov. 2019
Bearbeitet: James Tursa
am 18 Nov. 2019
Please do read here array indexing
n=20;
f=zeros(1,n);
f(1)=1;
f(2)=1;
for i=3:length(f)
f(i)=f(i-2)+f(i-1);
end
f
Please note: Without understanding the code, it has no meaning in your learning, hence I requested you to modify it and see the different results.
Antworten (0)
Diese Frage ist geschlossen.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!