0

I have digitized a video of a flying insect.

I have the x,y,z co-ordinates of the insects head and I have the x,y,z co-ordinates of the insects tail-end.

I can make two different scatter3 plots --- one of the head and the other of the tail.

But I want to combine these two scatter3 plots in such a way that, in the new scatter plot, the head and the tail are joined by a line.

It must be very easy to do this?

Black Dagger
  • 377
  • 2
  • 6
  • 18
  • Because you didn't show what you tried and why is not working for you, you are just asking for the solution, and that's not how SO should work. Plus if you like the answer, please accept it. – Ander Biguri Jun 17 '14 at 10:38
  • 1
    I wrote that I made scatter plots but I couldn't think beyond it. Cut me some slack brother. If you reduce my points like this I wont be able to ask more questions. Your answer has helped me figure out the solution. Thanks! – Black Dagger Jun 17 '14 at 10:45
  • 2
    @BlackDagger If you check the solution you see that he had to make many assumptions about names. If you had just posted/edited your question with an example set of data (e.g. 12 points) and how you constructed the scatter-plots. Ander Biguri could have used your variables and tested it with your example, making it a lot easier for him, the question easier to understand and at the same time showing that you tried doing it on your own. – The Minion Jun 17 '14 at 10:50

1 Answers1

1

Yeah, it is very easy to do this. Supposing you have same amount of heads and tails data. Probably there is a more efficient way of coding this, but hey, it works. I encourage anyone with a better coding skills than me to improve it ;)

figure()
hold on
scatter3d(Xhead, Yhead,Zhead ,'fill',[1 0 0])
scatter3d(Xtail, Ytail,Ztail ,'fill',[0 0 1])
for ii=1:length(Xhead)
    plot3([Xhead(ii) Xtail(ii)],[Yhead(ii) Ytail(ii)],[Zhead(ii) Ztail(ii)])
end
hold off
Ander Biguri
  • 35,140
  • 11
  • 74
  • 120