How could I find the maximum closed contour line?
23 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
My question is that how to find the maximum closed contour line.
Here's an example.
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 comentarios
Fernando Bello
el 12 de Jun. de 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
el 13 de Jun. de 2020
I have this function that a proffesor from Miami university posted ... This could work
Respuestas (1)
David Goodmanson
el 12 de Jun. de 2020
Editada: David Goodmanson
el 12 de Jun. de 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 comentarios
Ver también
Categorías
Más información sobre Surface and Mesh Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!