Get the Isocline from a know levelset plot (Contours) and the function output (Height)
13 次查看(过去 30 天)
显示 更早的评论
I was checking the function fcontour that we can use to get the contours like the following one.
I took the given example:
f = @(x,y) exp(-(x/3).^2-(y/3).^2) + exp(-(x+2).^2-(y+2).^2);
fc = fcontour(f)
- Now, I would like to see the heights of each contour.
- Suppose I have the height value, how do I get the points that belong the contour that corresponds to the height.
Regards...
采纳的回答
Mathieu NOE
2024-4-25
here a demo if you have one isocline , here I assumed we want only the outer portion (there could be also an inner isocline at same height)
the x,y coordinates are stored in xco, yco in my code
Z = peaks(50)/10;
level = 0.04;
surf(Z)
hold on
% extract outer isocline
[C,h] = contour(Z,level*[1 1]);
xc = C(1,2:end);
yc = C(2,2:end);
ind = find(xc==level);
% outer isocline
xco = xc(1:ind-1)
yco = yc(1:ind-1)
zco = level*ones(size(xco));
plot3(xco,yco,zco,'r','linewidth',5);
2 个评论
Mathieu NOE
2024-4-25
a more general code allows you to access multiple isoclines x,y coordinates (if several isoclines exist at a given z level)
here we have 2 isoclines at h = 0.04 (see blue and orange traces)
Z = peaks(50)/10;
level = 0.04;
surf(Z)
hold on
% extract all isocline for a given level
[C,h] = contour(Z,level*[1 1]);
[m,n] = size(C);
ind = find(C(1,:)==level); % index of beginning of each isocline data in C
ind = [ind n+1]; % add end (+1)
for k = 1:numel(ind)-1
xc = C(1,ind(k)+1:ind(k+1)-1);
yc = C(2,ind(k)+1:ind(k+1)-1);
zc = level*ones(size(xc));
plot3(xc,yc,zc,'linewidth',5);
end
hold off
Mathieu NOE
2024-4-25
I think I just reinvented the wheel !
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Digital Filter Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!