How to generate a curve describing a contour on 3D scatter plot
조회 수: 3 (최근 30일)
이전 댓글 표시
Hey,
I need some help defining the equation of the contour profile at a specified elevation from a list of 3D coordinates.
- I have a matrix A = [448100, 3] coordinates of X, Y, Z.
- Z ranges from 600 to 650 meters.
- I would like to mathematically describe the contours so I can extract a table of coordinate values at that specific elevation (Xs and Ys).
- Then I would be computing the contours at every meter interval so I have 'contour equations'
Does MATLAB have a function or does anyone have some idea on how I could do that?
The reason I would like to do this, is because I have two (2) data sets and I would like to measure movement between the two. If I define the same elevation contours on both data sets, I can cacluate the distance change of each contour line by generating points on each of the curves and then I can measure the average distance moved.
I have been able to isolate a fixed curve of the points, but I believe I am encountering issues generating a fitted curve on the values because it violates the principle definition of a function (only one y for every valid x).
Any ideas to overcome this?
*on the attached screenshot, all x and y have the same z value.
댓글 수: 0
답변 (1개)
Star Strider
2022년 3월 5일
댓글 수: 2
Star Strider
2022년 3월 6일
The ‘z’ values are the values of the contour.
This illustrates how to get the levels from a contour plot —
[X,Y,Z] = peaks(50);
figure
[M,C] = contour(X, Y, Z, 'ShowText',1);
Levels = C.LevelList % These Are The 'Z' Values For Each Contour
for k = 1:numel(Levels)
idx = find(M(1,:) == Levels(k));
ValidV = rem(M(2,idx),1) == 0;
StartIdx{k,:} = idx(ValidV);
VLen{k,:} = M(2,StartIdx{k});
end
figure
k1 = 4; % Index For Levels 'k1'
hold on
for k2 = 1:numel(StartIdx{k1})
idxv = StartIdx{k1}(k2)+1 : StartIdx{k1}(k2)+VLen{k1}(k2); % Index For Contour 'k1'
xv = M(1,idxv);
yv = M(2,idxv);
plot(xv, yv)
end
hold off
xlabel('M(1,:)')
ylabel('M(2,:)')
title(sprintf('Contour Level %.1f', Levels(k1)))
axis('equal')
Since the levels are functions of both ‘x’ and ‘y’, there will be a value of ‘z’ for each (x,y) pair for each section of the contour.
I am not certain how to create a mathematical model for each contour, since that depends on the surface being contoured.
.
참고 항목
카테고리
Help Center 및 File Exchange에서 Contour Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!