How can I add a point to an animation?
1 回表示 (過去 30 日間)
古いコメントを表示
I want to add the point b3 to the animation so that every in the end every b3 is in the animation
r =0;
s= 2;
z = [15, 0; 7, 10; 3, 4; 3, 6];
axis(gca, 'equal');
axis([0 16 0 20]);
k = 1;
for t = r:0.01:s
...
b3 = (1 - lambda ) * b2(1,:) + lambda * b2(2, :);
i
crank1 = line(z(:,1), z(:,2));
crank2 = line(b1(:,1), b1(:,2));
crank3 = line(b2(:,1), b2(:,2));
crank4 = line(b3(1), b3(2));
pause(0.1);
delete(crank1);
delete(crank2);
delete(crank3);
delete(crank4);
end
x = b3;
end
1 件のコメント
回答 (2 件)
Sayyed Ahmad
2018 年 6 月 27 日
you need to add in your code
hold on
otherweise you create every time a new graph and your point is not exist anymore.
0 件のコメント
Sammit Jain
2018 年 6 月 27 日
Hi, since the exact context of the code isn't clear, I'm making the following assumptions:
- You're probably trying to simulate/animate some form of a crank-slider mechanism.
- You're opening a figure window and plotting these lines continuously. These coordinates are updated in a for loop
- b3 is one point represented as [x,y]. (From the code it looks like it's a weighted average based on lambda)
In this case, your question boils down to representing a single point in a plot window. Now since you're animating, a simple way for you to do this is to use the 'viscircles' command. This will allow you to make an approximate representation of a point with a tiny circle.
With this you can make a visual representation of the ‘point’ by centering a circle on the x,y coordinates for the point (which are stored in b3), with a small radius. The circle will be drawn using the afore-mentioned viscircles command. You will have to choose a radius according to the scale of your animation.
Hope this helps.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Animation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!