Calculating pdf and cdf for data extracted as a table

조회 수: 4 (최근 30일)
Ali Awada
Ali Awada 2021년 9월 3일
댓글: Ali Awada 2021년 9월 4일
Hello,
I am trying to calculate the cdf and pdf of the wind speed using data extracted from a dat file using the readtable function:
data1 = readtable('FINO1_windspeed.dat', 'CommentStyle','#');
%TF = ismissing(data1,{-999});
data1 = standardizeMissing(data1,-999);
DateStrings = data1(:,1);
time_vector = datetime(DateStrings.Variables,'InputFormat','yyyy-MM-dd HH:mm:SS');
%plot(time_vector,data1.(2))
%Calculate the mean wind speed, its standard deviation and its variance
windspeedmean = nanmean(data1.(2))
windspeedstd = nanstd(data1.(2))
windspeedvar = nanvar(data1.(2))
%Calculate the pdf of wind speed
pdfwindspeed = pdf('Normal',A)
Where I have defined A as data1(:,2) because all the wind speed data are in the 2nd column. The first column is the time in a format of yyyy:MM:dd HH:mm:SS. The plot works just fine but the problem lays with the cdf and pdf calculations
I also tried A as data1.(2) but i get a long list of NaN.
Can anyone suggest a solution with an explanation for this?
Thanks for your help
  댓글 수: 2
the cyclist
the cyclist 2021년 9월 3일
Can you upload the data, or a subset of the data that gives the same problem?
Ali Awada
Ali Awada 2021년 9월 4일
Thanks for reaching out! I managed to sort out the problem

댓글을 달려면 로그인하십시오.

답변 (1개)

Jeff Miller
Jeff Miller 2021년 9월 4일
This command
pdfwindspeed = pdf('Normal',A)
returns the pdf of the A values within the standard normal with mu=0 and sigma=1. You might be getting nan's back if your A values come from a normal with a different mu & sigma. You should get more reasonable pdf values with something like this:
est_mu = mean(A);
est_sigma = std(A);
pdfwindspeed = pdf('Normal',A,est_mu,est_sigma);
  댓글 수: 1
Ali Awada
Ali Awada 2021년 9월 4일
Hey Jeff!
Thanks for explaining the command! You are exactly correct!
As for the other part i managed to get a similar answer yesterday after a lot of trial and error. it is similar to your suggestion
PS: if i insert f in the pd command it will give me an error(too many arguments)
windspeedmean = nanmean(data1.(2))
windspeedstd = nanstd(data1.(2))
d = data1.(1);
f = data1.Value;
%Calculate the pdf of wind speed
e = hour( data1.Time);
pd = makedist('Normal','mu',windspeedmean,'sigma',windspeedstd);
y = pdf(pd,e);

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Whos에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by