How do I put the patch in the correct position?
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
I have a longitude(x), latitude(y), altitude(z) data, which is aircraft data.
I made a patch using my data. but the patch is loacted in another position and y axis is not latitude number.
I don't know how to locate it in the correct position and how to use latitude(y) data for this.
so, I want the patch to be on trajectory like first image.
for i = 1:length(Dep_33L)
plot3(Dep_33L(i).Longitude, Dep_33L(i).Latitude, Dep_33L(i).BAlt)
hold on
end
yv = linspace(min(y), max(y), 30);
for k = 1:length(yv)
for i = 1:length(RKSI_Dep_33L)
x(i) = Dep_33L(i).Longitude(k);
z(i) = Dep_33L(i).BAlt(k);
end
xptcl = prctile(x,[2.5 97.5]);
zpctl = prctile(z,[2.5 97.5]);
xl(k,:) = xptcl;
zl(k,:) = zpctl;
patch([xptcl flip(xptcl)], [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)
xlabel('X')
ylabel('Y')
zlabel('Z')

채택된 답변
Star Strider
2022년 5월 27일
It appears that the ‘x’ and ‘y’ axes are reversed with respect to the data and the percentile patches. Keep the percentile patches as they are, and experiment with changing the data plot arguments so that they overlap correctly. (Without the axis labels and the axis gridlines, it is difficult to determine what needs to be changed.)
댓글 수: 13
first image is when 'y' is latitude.

second image is when 'y' is what you coded for me.

Strider, I really appreciate your help.
My pleasure!
The patch slices should be along ‘Y’ as they appear to be in the lower figure. The data are not plotted correctly against them. It might be necessary to experiment by permuting the order of the axes in the ‘Dep_33L’ data plot until it fits with the percentile patches.
Also, the lines connecting the patch corners do not appear to be plotting correctly, especially on the right (higher ‘X’ values) in the lower plot. It might be worthwhile to experiment with sorting the data by the ‘Y’ axis using either sort with the returned index, or sortrows sorting with respect to the ‘Y’ variable. I would do that first, and then see if it solves the other problems as well.
.
I tried to use sort and sortrows to sort 'y' data. but nothing changed in plotting.
do you think do i need to change this code what you coded earlier? especaily the 'y'
patch([xptcl flip(xptcl)], [0 1 1 0]+yv(k), [[1 1]*zpctl(1) [1 1]*zpctl(2)], 'r', 'FaceAlpha',0.5)
additionally, is there a way to flip a patch?
from two images above, I found that if yv = (min(y), max(y), 30) is large number, the plot is made well. and if yv is small number, the plot is wrong and the bounary's width is depend on yv.
I still have axis problem though.
I would not change my code.
I went on your original description in my code, so if the data are different from that, change the variable references in my code accordingly. It is likely that the altitude ‘z’ values will not change, however it might be worth switching the ‘x’ and ‘y’ references in my code to see if that changes the result.
The easiest way to do that would simply be to change the references prior to running my code, so define ‘x’ as latitude and ‘y’ as longitude. I would not change my code otherwise, since it works with the correct ‘x’ and ‘y’ references.
I would not flip the patches, or otherwise change my code. Leave them as they are, and just experiment with the ‘x’ and ‘y’ references.
If there are multiple lines joining the percentile patch corners (and especially if they zig-zag), then sorting with respect to ‘y’ might be appropriate. If there are single lines joining adjacent patch corners, just leave them as they are.
.
I still have same problem even though changed 'x' and 'y'.
first image is when yv is large number.
and second image is when yv is small number(real longitude). min(y) = 126.345 / max(y) = 126.454


The data being plotted and the data being given to my code are not exactly the same.
One possibility is that the ‘y’ data are reversed from the way they are presented to my code.
Try this —
yv = linspace(max(y), min(y), 30);
The rest of my code is unchanged.
.
Thanks, Strider.
The problem was this code.
for latitude, plus 1 is too large number. so the plot was made like that.
but i don't know which number do i should use for this instaed of 1.
[0 1 1 0]+yv(k)
That simply plots the percentile patch at a specific value of whatever ‘yv(k)’ is and is scaled by whatever it is. That does not control the dimensions of the prctile patches, just their placement with respect to ‘y’.
The dimensions of the patch are created by the prctile results that determine the height and width of the percentile patch. I suspect that there are outliers of some type in the ‘x’ data that are causing problems with the prctile calculations.
Anyway, to change the ‘y’ part of the patch, try something like this:
[0 1 1 0]*sf+yv(k)
where ‘sf’ is greater than 0 and less than 1.
.
the problem about 'y' value is solved.
but the result(first image) is not what i intended to make.
I want to have a patch like a second image using normal vector.
let me know how to make a patch using normval vector.
thanks!


In my original code, the percentile patches were approsimately normal to the direction of the vector, although fixed in the ‘y’ positions. It appears that the ‘x’ positions need to change, however I have no idea how to do that with respect to your data. I also have no idea what you changed to get that plot.
I canged the 'y'. I calculated the mean trajectory(longitude, latitude, altitude) of a lot of aircrafts data.
so I put the mean longtitude to the 'y' value, and it worked.
I need patch to be completly normal, not approximately.
Thanks again for your help, Strider.
That would likely require some sort of rotation matrix in 3 dimensions on each percentile patch. The rotation angle can likely be calcualted from the climb angle (typically 30° if I remember correctly) with the other angles remaining unchanged, since all aircraft would be expected to maintain runway heading (actually course) until reaching pattern altitude. They would then be vectored to their respective SID routes.
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;
z = z + t*cosd(30)*1E+3;
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;
hp = patch([xpctl flip(xpctl)], [0 1 1 0]+yv(k), [[1 1]*zpctl(1) [1 1]*zpctl(2)], 'r', 'FaceAlpha',0.25);
rotate(hp,[0.5 0 1],-30)
% vtx2 = get(hp,'Vertices')
xd(:,k) = hp.XData;
yd(:,k) = hp.YData;
zd(:,k) = hp.ZData;
end
% xd
% yd
% zd
% get(hp)
plot3(xd(1,:), yd(1,:), zd(1,:), '-k', 'LineWidth',2)
plot3(xd(2,:), yd(2,:), zd(2,:), '-k', 'LineWidth',2)
plot3(xd(3,:), yd(3,:), zd(3,:), '-k', 'LineWidth',2)
plot3(xd(4,:), yd(4,:), zd(4,:), '-k', 'LineWidth',2)
hold off
xlabel('X')
ylabel('Y')
zlabel('Z')
% xlim([120 140])
% ylim([100 400])
view(45,30)

I leave the rest to you. See the rotate documentation for details on how it works to make it work with your data.
.
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Polygons에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
