Filter löschen
Filter löschen

probability density function for a velocity data Vs. position

3 Ansichten (letzte 30 Tage)
Hussein Kokash
Hussein Kokash am 13 Jan. 2023
Beantwortet: Gokul Nath S J am 21 Apr. 2023
Hello,
I am trying to plot the probability density function of a velocity data I define from a .txt file, the output of the plot should resemble this:
Source: Wang, J. S., Feng, L. H., Wang, J. J., & Li, T. (2018). Görtler vortices in low-Reynolds-number flow over multi-element airfoil. Journal of Fluid Mechanics, 835, 898-935.
I have tried using the following code:
clear all; clc; close all;
path = pwd; % put current path here
addpath('/media/hf9098/easystore/MATLAB/power spectrum density')
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
[pdfValues,edges] = histcounts(V, 'Normalization', 'probability');
xIntervalCenters=(1/2)*(edges(1:end-1)+edges(2:end));
pdfValues=pdfValues/(edges(2)-edges(1));
normV = normpdf(V)
%plot Probability Density Function
figure(1);
plot(xIntervalCenters, pdfValues); grid on; zoom on;
xlabel('data value'); ylabel('pdf');
H = normpdf(V);
figure(2)
plot(y, H)
pd = makedist('Normal')
pdf_normal = pdf(pd,V);
figure(3)
plot(V,pdf_normal,'LineWidth',2)
end
Where in my code, the x-axis is y and the velocity is V
I am getting these plots which is far from the desired:
I have attached the data file.
Any ideas? Thank you and stay well!

Antworten (1)

Gokul Nath S J
Gokul Nath S J am 21 Apr. 2023
Hi Hussein,
Based on my understanding, I could observe that the data points in with respect to x-axis are not in ascending order. If you check specifically for the case of 2nd plot, you can observe that -0.042 is the last data points in the 2nd column of the .txt file. However, in between the data points (say from -0.08 and -0.07), you can find similar data values. This will indeed plot the graph in the opposite direction, as in this case towards the left side. Also that is the reason why if you closely observe in the 2nd graph, you can find the tip of the graph (x-value around -0.04) at the edge of the time instances to revert back and is terminating somwhere at the begining of the plot (x-value -0.11 to -0.1).
I strongly recommend you to take this underconsideration and plot the result.
Thanks,
Gokul Nath S J

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Produkte


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by