Borrar filtros
Borrar filtros

How to generate a curve describing a contour on 3D scatter plot

6 visualizaciones (últimos 30 días)
Brent Majcher
Brent Majcher el 5 de Mzo. de 2022
Comentada: Star Strider el 6 de Mzo. de 2022
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.

Respuestas (1)

Star Strider
Star Strider el 5 de Mzo. de 2022
I’m not certain what you want to do, however it is possible (although not straightforward) to extract the various contours using the M contour matrix output. Specify the contour levels using the levels input argument.
Defining the function as might be an option.
  2 comentarios
Brent Majcher
Brent Majcher el 6 de Mzo. de 2022
Thank you so much for responding and offering some advice.
The contour function is confusing to me. I have been able to generate the contours with:
[M,c] = contour(X,Y,Z);
This plots the attached photo... Matrix M is a size 2x10271... and I don't know where the Z values are stored. Can you offer some advice to what this function does? Are the z values stored in the c object?
Thanks again
Star Strider
Star Strider el 6 de Mzo. de 2022
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
Levels = 1×8
-6 -4 -2 0 2 4 6 8
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.
.

Iniciar sesión para comentar.

Categorías

Más información sobre Contour Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by