how to make a boundary using percentile?

2 ビュー (過去 30 日間)
Sierra
Sierra 2022 年 5 月 25 日
コメント済み: Star Strider 2022 年 5 月 25 日
i have trajectory data(longitude, latitude, altitude).
what i want to make is a boundary(second image). the boundary is made from mean trajectory using 'percentile'.
for example, if percentile is 100, the boundary includes every trajectory.
(In my case, the percentile will be 97.5.)
as you can see in third image, I can make a boundary with two elements(longitude, latitude). but my problem with making a boundary is that i have to consider three elements(longitude,latitude,altitude).
and the number of boundaries shoulde be the number of data. (if one trajectory data has 12 longitude, 12 latitude, 12 altitude data, the number of boundaries is 12 like second image.)
let me know how to make a boundary with three elements using 'percentile'.
thanks!

採用された回答

Star Strider
Star Strider 2022 年 5 月 25 日
This uses the prctile function —
x = rand(1,1000)*10+125;
y = randn(1,1000)*50+250;
xpctl = prctile(x,[2.5 97.5])
xpctl = 1×2
125.2398 134.6710
ypctl = prctile(y,[2.5 97.5])
ypctl = 1×2
154.4140 351.6244
figure
scatter(x,y,'.')
hold on
patch([xpctl flip(xpctl)], [[1 1]*ypctl(1) [1 1]*ypctl(2)], 'r', 'FaceAlpha',0.25)
hold off
xlim([120 140])
ylim([100 400])
Make appropriate changes to work with your data.
.
  5 件のコメント
Sierra
Sierra 2022 年 5 月 25 日
the process is
1) make a cross section at i th point of mean trajectory(red)
2) using percentile, make a boundary
3) connect i th boundray's vertices to i+1 th boundary's vertices
Star Strider
Star Strider 2022 年 5 月 25 日
As always, my pleasure!
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;
% xpctl = prctile(x,[2.5 97.5]);
% ypctl = prctile(y,[2.5 97.5]);
% zpctl = prctile(z,[2.5 97.5]);
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.75*yv(k) & y <=1.25*yv(k));
xpctl = prctile(x(yrng),[2.5 97.5]);
zpctl = prctile(z(yrng),[2.5 97.5]);
patch([xpctl flip(xpctl)], [0 1 1 0]+yv(k), [[1 1]*zpctl(1) [1 1]*zpctl(2)], 'r', 'FaceAlpha',0.25)
end
% xix = [1 1 1; 1 1 2; 1 2 2; 1 2 1];
% yix = [2 1 2; 1 1 2; 1 1 1; 2 1 1];
% zix = [2 1 2; 2 2 2; 1 2 2; 1 1 2];
% patch(xpctl(xix), ypctl(yix), zpctl(zix), 'r', 'FaceAlpha',0.25)
hold off
xlabel('X')
ylabel('Y')
zlabel('Z')
xlim([120 140])
ylim([100 400])
view(45,30)
If you want something else, it might be best for you to post this as a new Question. Include all the code and necessary data available. (It would also be appropriate to reference this thread by its URL.)
.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGeographic Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by