i have 3 coordinates x,y,z.. i have to plot it using plot3. my x,y,z coordinates gets updated in a for loop. i want all the points to get plotted in one plot using the default line style 'Solid line'. but ican't get it.i can only able to get using other line styles like 'o' , '.'.. Can anyone please help me with it???

 채택된 답변

Walter Roberson
Walter Roberson 2018년 3월 14일

1 개 추천

You cannot plot with solid line style if you only plot one point at a time.
You should save your data in vectors and plot3() the entire vector after the loop.
If you need the line to update during the run for animation purposes, then have a look at animatedline()

댓글 수: 6

Veera Kanmani
Veera Kanmani 2018년 3월 14일
instead of saving it in the vector, is there anyway to do it using handle
Walter Roberson
Walter Roberson 2018년 3월 14일
Yes, and the easiest way to do it using the handle is to use animatedline() to create the object and then use the methods to add points.
Veera Kanmani
Veera Kanmani 2018년 3월 14일
i have tried it.but animatedline is also not working for this case i have done as you said , but it is not working
Steven Lord
Steven Lord 2018년 3월 14일
Show us how you're trying to use animatedline. I just tried a simple example and it worked fine for me.
h = animatedline(NaN, NaN, NaN);
view(3)
axis([-1 1 -1 1 0 10]);
for z = 0:0.1:10
addpoints(h, sin(z), cos(z), z);
drawnow
end
Veera Kanmani
Veera Kanmani 2018년 3월 15일
편집: Walter Roberson 2018년 3월 15일
my x, y,z is not a function of z.. my x,y,z are the three different coordinates of an object. for example:
x=10;y=8;z=13;
then gets updated after some time (for every t=1:10) randomly...Now i have to plot these and connect all these points after time t.
Walter Roberson
Walter Roberson 2018년 3월 15일
편집: Walter Roberson 2018년 3월 15일
x = 0; y = 0; z = 0;
h = animatedline(x, y, z);
view(3)
for K = 1 : 100
x = x + randi([-1 1]);
y = y + randi([-1 2]);
z = z + randi([-2 1]);
addpoints(h, x, y, z);
drawnow();
end

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Animation에 대해 자세히 알아보기

태그

질문:

2018년 3월 14일

편집:

2018년 3월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by