how to make a cross section of lines and connect cross sections?

14 次查看(过去 30 天)
i have trajectory data(longitude, latitude, altitude).
I want to make a cross section of lines, which consist of data(longitude, latitude, altitude data). and connect i th boundray's vertices to i+1 th boundary's vertices, so i can make something like a tube.
the cross section(i will call it boundary) will be made using 'percentile'.
for example, if percentile is 100, the boundary includes every trajectory.
(In my case, the percentile will be 97.5.)
i know the process of this. but i have no idea of doing this by Matlab.
i will upload images of the process.
1) make a cross section at k th point of mean trajectory(red)
2) using percentile, make a boundary
3) connect k th boundray's vertices to k+1 th boundary's vertices
first image is the cross section of lines. red point is mean point of trajectory. and this boundary is made using 'specific percentile', so some trajectory data is out of boundary.

采纳的回答

Star Strider
Star Strider 2022-5-25
编辑:Star Strider 2022-5-26
I do not have your data, however consider something like this —
It would appear that the ‘y’ value is fixed in any specific location, so that it is only necessary to draw the percentile boxes with respecty to the ‘x’ and ‘z’ axes.
Example —
x = rand(1,5000)*10+125;
y = randn(1,5000)*50+250;
z = randn(1,5000)*150+300;
t = linspace(0, 1, 5000);
x = x + sin(2.5*pi*t)*125;
y = y + cos(1.5*pi*t)*125;
yv = linspace(min(y), max(y), 7); % Set 'Y' Values For The Box Locations
figure
scatter3(x,y,z,'.')
hold on
for k = 1:numel(yv)
yrng = find(y>=0.8*yv(k) & y <=1.2*yv(k));
xpctl = prctile(x(yrng),[2.5 97.5]);
zpctl = prctile(z(yrng),[2.5 97.5]);
xl(k,:) = xpctl;
zl(k,:) = zpctl;
patch([xpctl flip(xpctl)], [0 1 1 0]+yv(k), [[1 1]*zpctl(1) [1 1]*zpctl(2)], 'r', 'FaceAlpha',0.25)
end
plot3(xl(:,1), yv(:), zl(:,1), '-k', 'LineWidth',2)
plot3(xl(:,1), yv(:), zl(:,2), '-k', 'LineWidth',2)
plot3(xl(:,2), yv(:), zl(:,1), '-k', 'LineWidth',2)
plot3(xl(:,2), yv(:), zl(:,2), '-k', 'LineWidth',2)
hold off
xlabel('X')
ylabel('Y')
zlabel('Z')
% xlim([120 140])
% ylim([100 400])
view(45,30)
Make appropriate changes in my code to work with your data.
EDIT — (26 May 2022 at 00:50)
Added lines connecting the patch corners. (Away for most of the day today so did not get the opportunity to do this until now.)
.
  7 个评论
Sierra
Sierra 2022-5-27
Thanks, Strider. I understood
But I found that 'y' valuse is not fixed in one cross section, because the trajectory is tiltied, as you can see in first image.
and i have big trouble using your code for my output. but the result is not what i intended to make.
the second and third image is the result.
for i = 1:length(Dep_33L)
x = Dep_33L(i).Longitude;
y = Dep_33L(i).Latitude;
z = Dep_33L(i).BAlt;
t = linspace(0, 1, 30);
yv = linspace(min(y), max(y), 30); % Set 'Y' Values For The Box Locations
scatter3(x,y,z,'.')
hold on
end
for k = 1:length(yv)
for i = 1:length(Dep_33L)
x(i) = Dep_33L(i).Longitude(k);
z(i) = Dep_33L(i).BAlt(k);
end
xpctl = prctile(x,[2.5 97.5]);
zpctl = prctile(z,[2.5 97.5]);
xl(k,:) = xpctl;
zl(k,:) = zpctl;
patch([xpctl flip(xpctl)], [0 1 1 0]+yv(k), [[1 1]*zpctl(1) [1 1]*zpctl(2)], 'r', 'FaceAlpha',0.25)
end
plot3(xl(:,1), yv(:), zl(:,1), '-k', 'LineWidth',2)
plot3(xl(:,1), yv(:), zl(:,2), '-k', 'LineWidth',2)
plot3(xl(:,2), yv(:), zl(:,1), '-k', 'LineWidth',2)
plot3(xl(:,2), yv(:), zl(:,2), '-k', 'LineWidth',2)
hold off
xlabel('X')
ylabel('Y')
zlabel('Z')
% xlim([120 140])
% ylim([100 400])
Star Strider
Star Strider 2022-5-27
I am not certain how to fix those problems.
My code is based on the information originally provided and the diagrams describing the desired result.
Perhaps adjusting the prctile limits will work, since the ‘xpctl’ value appears to be the problem.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Geographic Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by