MATLAB Answers

How could I find the maximum closed contour line?

조회 수: 30(최근 30일)
Yingzhe Cui
Yingzhe Cui 5 Nov 2019
댓글: Fernando Bello 13 Jun 2020
My question is that how to find the maximum closed contour line.
Here's an example.
TIM截图20191105131501.jpg
There are contour lines of the local streamfunction value.
I want to find the closed contour line with the maximum value of the local streamfunction.
How can I do that using Matlab instead of manual detection?
The background is the flow field.
Any help is appreciated.

  댓글 수: 3

darova
darova 5 Nov 2019
YOu can use
h = 10; % height you want the contour at
contourf(x,y,z,[h h])
To create ONE contour at specific height
Fernando Bello
Fernando Bello 12 Jun 2020
This will not work because it will draw all contours of that height. So If you have a line close by of that height it will be extracted too.
Fernando Bello
Fernando Bello 13 Jun 2020
I have this function that a proffesor from Miami university posted ... This could work

Sign in to comment.

답변(1개)

David Goodmanson
David Goodmanson 12 Jun 2020
편집: David Goodmanson 12 Jun 2020
Hello YC,
Since a saddle point is where the contour lines go from closed to open, the idea is to find the location of the saddle point and evaluate the value of the streamline function there. That value is the maximum closed-streamline value, given that you are encircling a local minimum.
The method here uses a numerical gradient and not an analytical one, so occasionally the location might end up on a corner of the plot or somewhere like that. In that case you would just have to narrow the search to the appropriate region. Decreasing the spacing in x and y gives a more accurate answer but a denser plot.
% create streamline function
xx = -10:.4:10;
yy = -10:.4:10;
[x y] = meshgrid(xx,yy);
x0 = -5.1;
y0 = -3.5;
x1 = 4;
y1 = 3.1;
S = @(x,y) -sqrt(1./(5+(x-x0).^2+2*(y-y0).^2) + 1./(5+2*(x-x1).^2+(y-y1).^2));
% find where gradient of S is approximately zero
[gx gy] = gradient(S(x,y));
norm2 = gx.^2+gy.^2; % function to minimize
[a ind] = min(norm2,[],'all','linear')
[j k] = ind2sub([numel(xx) numel(yy)],ind)
x0 = xx(k); % saddle point location
y0 = yy(j);
S(x0,y0) % max streamline value
% plot
figure(1)
quiver(x,y,gy,-gx)
hold on
contour(x,y,S(x,y))
%colorbar
plot(x0,y0,'o')
grid on
hold off

  댓글 수: 0

Sign in to comment.

태그

제품


릴리스

R2019b

Translated by