Cobweb graph
이전 댓글 표시
I want to draw a cobweb graph for sin(x). Here is a code (based on an online source) that seem to fail to work, grateful if someone could help me troubleshoot or suggest a better code.
function cobweb(f,a,b,x0,x1,N)
x(1)=-2; % plot orbit starting at x0
for i=1:99
x(i+1)= sin(x(i));
plot([x(i),x(i)],[x(i),x(i+1)]);
hold on
plot([x(i),x(i+1)],[x(i+1),x(i+1)]);
hold on
end
hold off
Thanks.
댓글 수: 2
Fangjun Jiang
2011년 8월 20일
What is failing? Don't assume everybody knows cobweb graph. This is a MATLAB forum.
Richard
2011년 8월 21일
채택된 답변
추가 답변 (1개)
Fangjun Jiang
2011년 8월 20일
0 개 추천
There is a nice animation here. I think it needs some if-statement in your code.
카테고리
도움말 센터 및 File Exchange에서 Programming에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!