Contour line plot corresponding to sharpest changes
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
Nathan Hardenberg
2023-9-19
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)
回答(0 个)
另请参阅
类别
在 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!