integral of contour plot
16 views (last 30 days)
I would like to compute the circulation from a velocity field. From my understanding the circulation can be computed from surface integral of vorticity plot (curl).
My input parameters are be X,Y,U,V which are all 2D matrices.
I think I found a solution for a retangular surface https://uk.mathworks.com/matlabcentral/answers/36218-surface-integral-of-discrete-data but I would like to carry out an integral over a contour plot.
I basically have the same problem as previously posted https://uk.mathworks.com/matlabcentral/answers/307767-how-to-integrate-the-data-from-contour-over-a-surface but I couldn't find the solution.
I am very poor with coding and some line of codes would be much appreciated.
Nathaniel H Werner on 2 Aug 2019
Edited: Nathaniel H Werner on 7 Aug 2019
You can calculate the circulation using the bounds of a contour in 2018b.
I completed this on cylindrical slices for my purposes, but I'm sure you can adjust this. You will need velocity data, not vorticity to use the code I have provided but the results will be equivalent.
R = 1;
Nt = floor(2.1*50*R);
[Xc,Zc,Yc] = cylinder(R*ones(1,50),Nt);
hsli = contourslice(Xw,Yw,Zw,D_ta,Xc,Yc,Zc,[-3,-3],'linear');
% D_ta is the name of my vorticity field in this case.
% You can always use other terms to define your contour, or just choose an arbitrary shape.
hsli.LineWidth = 2;
hsli.EdgeColor = [144,144,144]/255;
Xcs = hsli.XData; Xcs = Xcs(1:end-1);
Ycs = hsli.YData; Ycs = Ycs(1:end-1);
Zcs = hsli.ZData; Zcs = Zcs(1:end-1);
ux_loc = interp3(Xw,Yw,Zw,Ux,Xcs,Ycs,Zcs);
uy_loc = interp3(Xw,Yw,Zw,Uy,Xcs,Ycs,Zcs);
uz_loc = interp3(Xw,Yw,Zw,Uz,Xcs,Ycs,Zcs);
GammaLoc = zeros(1,length(Xcs));
for g = 1:length(Xcs)-1
dl = [Xcs(g+1)-Xcs(g),...
GammaLoc(g) = dot([ux_loc(g),uy_loc(g),uz_loc(g)],...
Gamma = sum(GammaLoc);