how to make a boundary using percentile?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Sierra
am 25 Mai 2022
Kommentiert: Star Strider
am 25 Mai 2022



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!
0 Kommentare
Akzeptierte Antwort
Star Strider
am 25 Mai 2022
x = rand(1,1000)*10+125;
y = randn(1,1000)*50+250;
xpctl = prctile(x,[2.5 97.5])
ypctl = prctile(y,[2.5 97.5])
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 Kommentare
Star Strider
am 25 Mai 2022
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.)
.
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!






