Borrar filtros
Borrar filtros

Contour line plot corresponding to sharpest changes

1 visualización (últimos 30 días)
Ban
Ban el 25 de Ag. de 2023
Comentada: Nathan Hardenberg el 19 de Sept. de 2023
Please refer the contour plot. The contour shows sharp changes of values along 2 vertically varying lines. I want to get the values of those lines and would like to draw dotted lines along those 2 lines of sharpest changes. Please help.
  1 comentario
Nathan Hardenberg
Nathan Hardenberg el 19 de Sept. de 2023
Maybe there is a better way, but this is an idea I had. You are not able to plot a line, but you plot points with high gradient instead.
% create example
x = -1:0.2:1;
y = x;
[X,Y] = meshgrid(x,y);
Z = heaviside(X - Y*0.5 + (Y+1).^2.*0.1) + rand(size(X))*0.06;
figure(1);
surf(X,Y,Z,'FaceColor','interp'); view(3) % plot example
gradientZ = abs(gradient(Z)); % calculate gradient (aka: how "sharp" the surface is)
figure(2);
surf(X,Y,gradientZ,'FaceColor','interp')
sharp = gradientZ > 0.3 % value for fine tuning | select only "sharp" changes
sharp = 11×11 logical array
0 0 1 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0
% plot "sharp" points on the contour
figure(3); hold on;
contourf(X,Y,Z)
scatter(X(sharp), Y(sharp),'*','r','LineWidth',2)

Iniciar sesión para comentar.

Respuestas (0)

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