how to azimuthally average a N*N data ?

6 次查看(过去 30 天)
I have a 291*291 velocity data from LES . I want to azimuthally average the data so that for any angle from the origin at a particular radial distance i get the same value of velocity.
please suggest the way to do it.
Following figure shows the pictorial reperesentation of velocity data in yz plane
here is the attached file for the data

回答(1 个)

Star Strider
Star Strider 2024-8-11
I seriously doubt that what you want to do is possible, simply because your data do not work that way,
Likely the best you can do is to use the scatteredInterpolant function to interpolate one value as a function of the other two.
That would go something like this —
files = dir('*.txt');
for k = 1:numel(files)
filename = files(k).name
A{k} = readmatrix(filename);
end
filename = 'u11.txt'
filename = 'y1.txt'
filename = 'z1.txt'
V = A{1};
X = A{2};
Y = A{3};
[Vmin,Vmax] = bounds(V,'all')
Vmin = -0.0094
Vmax = 0.3075
[Xmin,Xmax] = bounds(X,'all')
Xmin = -6.4631
Xmax = 5.5760
[Ymin,Ymax] = bounds(Y,'all')
Ymin = -6.4583
Ymax = 5.5812
[A,R,Z] = cart2pol(X, Y, V);
[Amin,Amax] = bounds(A,'all')
Amin = -3.1389
Amax = 3.1411
[Rmin,Rmax] = bounds(R,'all')
Rmin = 0.0056
Rmax = 9.1315
[Vmin,Vmax] = bounds(Z,'all')
Vmin = -0.0094
Vmax = 0.3075
Farv = scatteredInterpolant(A(:),R(:),Z(:)); % Velocity As A Function Of Angle & Radius
Favr = scatteredInterpolant(A(:),Z(:),R(:)); % Radius As A Function Of Angle & Velocuty
Frva = scatteredInterpolant(R(:),Z(:),A(:)); % Angle As A Function Of Radius & Velocity
N = 10;
Aq = linspace(Amin, Amax, N).';
Rq = linspace(Rmin, Rmax, N).';
Vi = Farv(Aq, Rq);
ARV_Interpolations = table(Aq, Rq, Vi, 'VariableNames',{'Angle (radians)','Radius','Velocity'})
ARV_Interpolations = 10x3 table
Angle (radians) Radius Velocity _______________ _________ __________ -3.1389 0.0056004 0.30167 -2.4411 1.0196 0.23859 -1.7433 2.0336 0.12867 -1.0456 3.0476 0.072741 -0.34777 4.0616 0.024575 0.35 5.0755 -0.0064853 1.0478 6.0895 -0.0058249 1.7456 7.1035 -0.0059815 2.4433 8.1175 -0.0057644 3.1411 9.1315 -0.0058383
N = 10;
Aq = linspace(Amin, Amax, N).';
Vq = linspace(Vmin, Vmax, N).';
Ri = Favr(Aq, Vq);
AVR_Interpolations = table(Aq, Vq, Ri, 'VariableNames',{'Angle (radians)','Velocity','Radius'})
AVR_Interpolations = 10x3 table
Angle (radians) Velocity Radius _______________ __________ _______ -3.1389 -0.0093831 9.4498 -2.4411 0.025822 3.8114 -1.7433 0.061027 2.6731 -1.0456 0.096232 2.5875 -0.34777 0.13144 2.5345 0.35 0.16664 1.6565 1.0478 0.20185 1.0082 1.7456 0.23705 0.77004 2.4433 0.27226 0.52475 3.1411 0.30746 0.43572
N = 10;
Rq = linspace(Rmin, Rmax, N).';
Vq = linspace(Vmin, Vmax, N).';
Ai = Frva(Rq, Vq);
RVA_Interpolations = table(Rq, Vq, Ai, 'VariableNames',{'Radius','Velocity','Angle (radians)'})
RVA_Interpolations = 10x3 table
Radius Velocity Angle (radians) _________ __________ _______________ 0.0056004 -0.0093831 -873.3 1.0196 0.025822 -176.62 2.0336 0.061027 0.53339 3.0476 0.096232 0.73956 4.0616 0.13144 2.5574 5.0755 0.16664 -0.52377 6.0895 0.20185 0.68435 7.1035 0.23705 0.83499 8.1175 0.27226 -0.071844 9.1315 0.30746 -2.0362
figure
hs = surfc(X, Y, V, 'EdgeColor','interp');
colormap(turbo)
xlabel('X')
ylabel('Y')
zlabel('Velocity')
daspect([1 1 0.05])
figure
[c,hc] = contour(X, Y, V, 'ShowText',1);
colormap(turbo)
axis('equal')
This gives an example of thte interpolation approach. The various funcitons created by scatteredInterpolant will return appropriate values for any of the first two arguments that are within their limits, as calculated using the bounds calls.
.

产品


版本

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by