Contour line plot corresponding to sharpest changes
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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
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
% plot "sharp" points on the contour
figure(3); hold on;
contourf(X,Y,Z)
scatter(X(sharp), Y(sharp),'*','r','LineWidth',2)
Respuestas (0)
Ver también
Categorías
Más información sobre Contour Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!