Get the Isocline from a know levelset plot (Contours) and the function output (Height)
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Prasanna Routray
am 25 Apr. 2024
Kommentiert: Mathieu NOE
am 25 Apr. 2024
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 Kommentare
Akzeptierte Antwort
Mathieu NOE
am 25 Apr. 2024
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 Kommentare
Mathieu NOE
am 25 Apr. 2024
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
am 25 Apr. 2024
I think I just reinvented the wheel !
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Digital Filter Analysis finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!