how to azimuthally average a N*N data ?
3 views (last 30 days)
Show older comments
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
0 Comments
Answers (1)
Star Strider
on 11 Aug 2024
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
V = A{1};
X = A{2};
Y = A{3};
[Vmin,Vmax] = bounds(V,'all')
[Xmin,Xmax] = bounds(X,'all')
[Ymin,Ymax] = bounds(Y,'all')
[A,R,Z] = cart2pol(X, Y, V);
[Amin,Amax] = bounds(A,'all')
[Rmin,Rmax] = bounds(R,'all')
[Vmin,Vmax] = bounds(Z,'all')
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'})
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'})
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)'})
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.
.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!