Visualise 3D trajectory data as a volume plot

I have 3D trajectory data (x, y, z coordinates) which I would like to visualise as a volume plot. I'm using plot3 but just getting a line plot - see attached pdf with images of what I'm getting using plot3 and what I would like to get.
I've also attached a .mat file containing my 3D-trajectory data.
Many thanks for your help.

2 件のコメント

KSSV
KSSV 2018 年 7 月 26 日
編集済み: KSSV 2018 年 7 月 26 日
Huumhh..it looks complex for me.....Do you need to remove some points? There is difference in the line plot and the plot you wanted..
Impala
Impala 2018 年 7 月 26 日
Yes, points can be removed - its just for visualisation purposes.
I have read posts on similar topics but haven't been successful so far. I'm getting stuck on the bit where I need to transform my 3D trajectory data into a form that the matlab volume visualisation tools can use as inputs.

サインインしてコメントする。

 採用された回答

KSSV
KSSV 2018 年 7 月 26 日
編集済み: KSSV 2018 年 7 月 27 日

3 投票

Check the below trial code:
S = matfile('C:\Users\srinivas\Downloads\3DTraj.mat') ;
x = S.xSmooth ;
y = S.ySmooth ;
z = S.zSmooth ;
x = x(1:5:end) ; y = y(1:5:end) ; z = z(1:5:end) ;
N = [diff(x) diff(y) diff(z)] ;
C = 20*ones(size(x)) ;
figure
hold on
plot3(x,y,z,'r')
Cx = zeros([],[]) ;
Cy = zeros([],[]) ;
Cz = zeros([],[]) ;
for i = 1:1:length(x)-1
center = [x(i) y(i) z(i)] ;
normal = [N(i,1) N(i,2) N(i,3)] ;
radius = C(i) ;
P = plotCircle3D(center,normal,radius) ;
Cx(i,:) = P(1,:);
Cy(i,:) = P(2,:);
Cz(i,:) = P(3,:);
end
h = mesh(Cx,Cy,Cz) ; shading interp
h.FaceAlpha = 0.5 ;
Download the functions from the link:

5 件のコメント

Impala
Impala 2018 年 7 月 26 日
Ah I see, you've created a circle around each point to fill the volume! This is perfect! Thank you for your help and prompt solution!
KSSV
KSSV 2018 年 7 月 26 日
It needs some changes...I will do that tomorrow..I am on the way to home now...
Impala
Impala 2018 年 7 月 26 日
Thanks very much - I look forward to the changes.
KSSV
KSSV 2018 年 7 月 27 日
Edited the code...:)
Impala
Impala 2018 年 7 月 27 日
This works really well :) thank you so much! One last question - how do I get it to be the same colour throughout and also a little transparent so I can see the line plot through it? I've tried modifying the h.FaceColor and h.FaceAlpha values but it's not doing anything.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

質問済み:

2018 年 7 月 26 日

コメント済み:

2018 年 7 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by