how to know 'y' values perpendicular to a line?
Show older comments

I have longitude, latitude, altitude data of aircraft. and I plotted trajectoris of aircrafts(I only drawed mean trajecorty here. and drawed 2D)
a left image is what I plotted with patch(using percentile). but it's something wrong.
percentile ex) If percentile is 100, the patch contain every trajectory. In my case, I use 97.5 percentile.
I need to plot like a right image. the line between two y values should be perpendicular to a mean trajectory(black line).
I know it's because I assgin two y values(not to mean trajetroy's y value) to same value as mean trajectory's y value.
but I don't know how to get a two y values which is perpendicular to each mean trajectory point.
I will attach my code for your understanding.
Thanks.
for i = 1:length(33R)
plot3(33R(i).Longitude, 33R(i).Latitude,33R(i).BAlt)
hold on
end
hold on
xlabel('X')
ylabel('Y')
zlabel('Z')
yv = [];
yv = [yv;mean_trajectory.Latitude]; % I fixed 'y' values I think it's a problem.
for i = 1:length(trajectory) % trajectory is every trajectory of aicraft incluing mean trajectory.
xptcl = prctile(trajectory(i).Longitude,[2.5 97.5]); % I used percentile when making a patch
zptcl = prctile(trajectory(i).Altitude,[2.5 97.5]); % same
xl(i,:) = xptcl;
zl(i,:) = zptcl;
patch([xptcl flip(xptcl)], [0 0 0 0]+yv(i), [[1 1]*zptcl(1) [1 1]*zptcl(2)],'r', 'FaceAlpha',0.5)
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)
grid on
Accepted Answer
More Answers (0)
Categories
Find more on Polar Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!