필터 지우기
필터 지우기

How to use comet to trace the path of an object?

조회 수: 8 (최근 30일)
reema shrestha
reema shrestha 2017년 7월 8일
댓글: Image Analyst 2017년 7월 9일
I am writing a code for the simulation of double pendulum and i need to trace the path of the bob. But I am having trouble with it. This is a part of my code. Basically,i am having trouble in this portion. Though I use the command comet,it doesn't trace the path. Anyone who could point out my mistake and help me solve the problem? Here x1(i),y1(i) is the poition of first bob.
for i = 1 : max(arraysize)
plotarrayy = [pendulumtopy y1(i)]; % Plots solution at each time interval
plotarrayx = [pendulumtopx x1(i)];
plotarray2x = [x1(i) x2(i)];
plotarray2y = [y1(i) y2(i)];
plot(x1(i),y1(i),'ro',x2(i),y2(i),'bo','markersize',5,'markerfacecolor','r')
hold on
comet(y1(i));

답변 (1개)

jonatan
jonatan 2017년 7월 8일
comet requires the input(s) to be a vector and not a single value, as you wrote. In order to use this function, you should run it after the for loop:
comet(x1,y1)
  댓글 수: 2
reema shrestha
reema shrestha 2017년 7월 9일
What should be the input for the comet outside the loop? I tried using
comet(y(i))
But then i only runs inside loop,isn't it??
Image Analyst
Image Analyst 2017년 7월 9일
Outside the loop, it should be what he said it should be:
comet(x1,y1)
Why did you change it?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by