Bifurcation Diagram of Logistic Equation -- Unnecessary Lines in Code?
이전 댓글 표시
clear all, close all,clc
xvals=[];
for beta =0:0.01:4
beta
xold = 0.5;
for i = 1:2000
xnew = ((xold-xold^2)*beta);
xold = xnew;
end
xss = xnew;
for i = 1:1000;
xnew = ((xold-xold^2)*beta);
xold = xnew;
xvals(1,length(xvals)+1) = beta;
xvals(2,length(xvals)) = xnew;
if (abs(xnew-xss) < .001)
break
end
end
end
plot (xvals(1,:),xvals(2,:),'.')
Hello again,
I was following a youtube tutorial by Steve Brunton, (link:https://www.youtube.com/watch?v=_BvAkyuWhOI&t=395s),to create the bifurcation diagram of the logistic map, and I don' seem to understand what the purpose of this block of code is:
for i = 1:2000
xnew = ((xold-xold^2)*beta);
xold = xnew;
end
The next for loop I understand, but the one I quoted above does not make sense to me. Also, for the last loop (i = 1:1000), how/why did the length of the array change (we had to add one to the length) ?
Thank you in advance and thank you for your patience, as I am fairly new to numerical programming
답변 (1개)
Guru Mohanty
2020년 4월 15일
After debugging your code, it seems the section of code you mentioned is irreverent, because of following reasons.
for i = 1:2000
xnew = ((xold-xold^2)*beta);
xold = xnew
end
- Inside the for loop there is no expressions depending on the index ‘i’. So the execution of above two line will continue 2000 times.
- Each time the loop executes, the value of ‘xnew’ and ‘xold’ keep on decreasing and after the for-loop execution value of ‘xnew’ and ‘xold’ becomes Zero.
카테고리
도움말 센터 및 File Exchange에서 General Applications에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!