Get the Isocline from a know levelset plot (Contours) and the function output (Height)
조회 수: 15 (최근 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...
댓글 수: 3
채택된 답변
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!