Root mean square of velocity fluctuations
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hussein Kokash
el 28 de Dic. de 2022
Comentada: Star Strider
el 28 de Dic. de 2022
Hello,
I am trying to calculate root mean square of velocity fluctuations in a 2D plane (x,y) coordinates with (U, V) velocity values.
Total number of points I have are 4489.
What am looking for is something like this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1245887/image.jpeg)
Image reference: Lin, L. M., & Wu, Y. X. (2018). New interpretation of specific sign of Reynolds stress in the boundary layer on a flat plate. Theoretical and Applied Mechanics Letters, 8(6), 372-377.
I have tried the rms function:
clear all; clc; %close all;
path = pwd;
R = dir(fullfile(path,'data_2.txt'));
S = natsortfiles(R);
if iscell(S) == 0;
S = (S);
end
for k = 1:numel(S)
folder = S(k).folder;
filename = S(k).name;
F = fullfile(S(k).folder,S(k).name);
data = dlmread(F);
x = data(:,1); % x coordinate
y = data(:,2); % y coordinate
U(:,k) = data(:,4); % u velocity
V(:,k) = data(:,5); % v velocity
M_data = mean(V);
RMS_data = rms(V);
VrmsC = sqrt(mean(V.^2,2))/C; % RMS Velocity/C
figure
plot(y, V)
plot(xlim, [1 1]*M_data, 'LineWidth',1.5) plot(xlim, [1 1]*RMS_data, 'LineWidth',1.5)
plot(VrmsC, y, 'LineWidth',1.5)
plot (y, RMS_data)
end
But with no luck getting something similar to the figure above.
The data file is attached if needed.
Any thoughts how to do so?
Thank you
0 comentarios
Respuesta aceptada
Star Strider
el 28 de Dic. de 2022
The data are gridded, and actually for surfaces.
How do you want to calculate the RMS value of a surface?
data = readmatrix('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1245882/data_2.txt')
x = data(:,1); % x coordinate
y = data(:,2); % y coordinate
U = data(:,4); % u velocity
V = data(:,5); % v velocity
[Ux,ix] = unique(x);
Uix = unique(diff(ix))
[Uy,iy] = unique(y);
N = Uix;
xv = linspace(min(x), max(x), N);
yv = linspace(min(y), max(y), N);
[X,Y] = ndgrid(xv,yv);
Um = reshape(U,Uix,[]);
Vm = reshape(V,Uix,[]);
RMS_U = sqrt(mean(Um.^2))
RMS_V = sqrt(mean(Vm.^2))
figure
plot(RMS_U, 'DisplayName','RMS(U)')
hold on
plot(RMS_V, 'DisplayName','RMS(V)')
hold off
grid
legend('Location','best')
figure
surfc(X,Y,Um)
grid on
colormap(turbo)
xlabel('X')
ylabel('Y')
zlabel('U')
figure
surfc(X,Y,Vm)
grid on
colormap(turbo)
xlabel('X')
ylabel('Y')
zlabel('V')
This calculates the RMS values by using the square root of the square of the column mean for each surface.
Experiment to get the result you want. See the documentation on mean to take the unweighted mean across the rows instead.
.
2 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Data Distribution 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!