Histogram and Rayleigh distribuition

Click For Summary
SUMMARY

The discussion focuses on calculating histograms for wave height and wave period using MATLAB, specifically addressing the comparison with the Rayleigh distribution. The user encountered an error with the 'histfit' function, which is undefined for double input arguments. The provided MATLAB code processes wave data from a text file, calculates zero crossings, wave periods, and heights, and computes mean values. The user seeks assistance in generating histograms and applying the Rayleigh distribution using the 'histfit' function.

PREREQUISITES
  • Familiarity with MATLAB programming and syntax
  • Understanding of wave height and wave period concepts
  • Knowledge of Rayleigh distribution and its applications
  • Experience with data processing and visualization in MATLAB
NEXT STEPS
  • Resolve the 'histfit' function error in MATLAB by checking the Statistics and Machine Learning Toolbox installation
  • Learn how to create histograms in MATLAB using the 'histogram' function
  • Study the implementation of Rayleigh distribution fitting in MATLAB
  • Explore exceedance probability distribution calculations and their visualizations
USEFUL FOR

Students and researchers in oceanography, data analysts working with wave data, and MATLAB users interested in statistical analysis and visualization techniques.

Jay Sebi
Messages
1
Reaction score
0

Homework Statement


  1. (iv) Calculatethehistogramforthewaveheightandwaveperiod.
  2. (v) Compare the histogram with the Rayleigh distribution.
  3. (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.
I have in MATLAB this code that gives me the periods and wave height for each period.
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.
 
Physics news on Phys.org
Thanks for the post! Sorry you aren't generating responses at the moment. Do you have any further information, come to any new conclusions or is it possible to reword the post?
 

Similar threads

Replies
13
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 4 ·
Replies
4
Views
8K
  • · Replies 27 ·
Replies
27
Views
2K
  • · Replies 11 ·
Replies
11
Views
1K
  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 1 ·
Replies
1
Views
950
  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 31 ·
2
Replies
31
Views
5K