connecting points in scatter3 plot?

조회 수: 66 (최근 30일)
Sanjoy Basak
Sanjoy Basak 2014년 11월 4일
답변: Sanjoy Basak 2014년 11월 4일
hi there. I am trying to connect points in a scatter3 plot. i tried using line, but that is applicable for 2D plot. but the data contains 3 dimensions. can anyone please tell me which command should i use after the line to connect points? thanks in advance.

채택된 답변

Matt Tearle
Matt Tearle 2014년 11월 4일
OK, now I understand the problem. The issue isn't that the data is representing 3-dimensional points, but that it's stored in a 3-D array. So you need to squeeze or reshape your data into vectors:
x = objlist.r_c(1,1,:);
x = x(:);
y = objlist.r_c(2,1,:);
y = y(:);
z = objlist.r_c(3,1,:);
z = z(:);
% or plot3(x,y,z,'o-')
x = squeeze(objlist.r_c(1,1,:));
y = squeeze(objlist.r_c(2,1,:));
z = squeeze(objlist.r_c(3,1,:));

추가 답변 (3개)

Matt Tearle
Matt Tearle 2014년 11월 4일
편집: Matt Tearle 2014년 11월 4일
What about plot3?
But I also don't understand what the problem is with line. This does the same as plot3:
x = rand(5,1);
y = rand(5,1);
z = rand(5,1);

Sanjoy Basak
Sanjoy Basak 2014년 11월 4일
my data has 3 dimensions as you can see here..
(objlist.r_c(1,1,:) there is a z dimension here.. line only deals with 2 dimension points..line is not working..can you tell me any other way or any other command to join the points? no just a straight line, something else like spline would also be fine..

Sanjoy Basak
Sanjoy Basak 2014년 11월 4일
thank you very it is working fine..:)


Help CenterFile Exchange에서 Smoothing에 대해 자세히 알아보기


Community Treasure Hunt

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

Start Hunting!

Translated by