- #1
Jay Sebi
- 1
- 0
Homework Statement
- (iv) Calculatethehistogramforthewaveheightandwaveperiod.
- (v) Compare the histogram with the Rayleigh distribution.
- (vi) Calculate exceedance probability distribution for the wave height and wave period using plotting position formulae and compare it with Rayleigh distribution exceedance probability distribution.
code:
clc
clear all
filename = '/Users/helenapereira/Desktop/A1-Wave Data.txt';
delimiter = '\t';
startRow = 3;
formatSpec = '%f%f%[^\n\r]';
fileID = fopen(filename,'r');
dataArray = textscan(fileID, formatSpec, 'Delimiter', delimiter, 'HeaderLines' ,startRow-1, 'ReturnOnError', false);
fclose(fileID);
Time = dataArray{:, 1};
WAVE = dataArray{:, 2};
clearvars filenamedelimiterstartRowformatSpecfileIDdataArrayans;%%%UPCROSS%%%
% Finding Zeros
ii=1;
for i=1:length(WAVE)-1
if and(WAVE(i)<0,WAVE(i+1)>0)
Indices(ii)=i;
ii=ii+1;
end
end
%Zero Crossing
for i=1:length(Indices)
ZeroCrossing(i)=interp1(WAVE(Indices(i):Indices(i)+1),Time(Indices(i):Indices(i)+1),0,'linear');
end
%Period
ii=1;
for i=1:length(ZeroCrossing)-1
Period(ii)=ZeroCrossing(i+1)-ZeroCrossing(i);
ii=ii+1;
end
%Wave Height
ii=1;
for i=1:length(Indices)-1
Wmax=max(WAVE(Indices(i):Indices(i+1)));
Wmin=min(WAVE(Indices(i):Indices(i+1)));
H(ii)=Wmax-Wmin;
ii=ii+1;
end
%Mean Wave Height
Hmed=mean(H);
%Mean Wave Period
Tmed=mean(Period);
%Hs and H1/10
sort(H,'descend');
a=ceil(length(H)/3);
b=ceil(length(H)/10);
Hs=mean(H(1:a));
Hdec=mean(H(1:b));
%Ts and T1/10
sort(Period,'descend');
c=ceil(length(Period)/3);
d=ceil(length(Period)/10);
Ts=mean(Period(1:c));
Tdec=mean(Period(1:d));
I now need to make the histograms.
however the function histfit gives me the error:
Undefined function 'histfit' for input arguments of
type 'double'.
Homework Equations
the histfit equation on matlab
The Attempt at a Solution
Use histfit equation to get the histogram and rayleigh distribuition.