Date: Jan 29, 2013 7:45 PM
Author: Derek Goring
Subject: Re: Zero Crossing

On Wednesday, January 30, 2013 9:05:09 AM UTC+13, Pete  wrote:
> TideMan <mulgor@gmail.com> wrote in message <b59569bf-fa63-42d8-86d5-033c57434476@googlegroups.com>...
>

> > On Tuesday, January 29, 2013 5:08:08 AM UTC+13, Pete wrote:
>
> > > Hi,
>
> > >
>
> > > I'm very new to matlab and need to calculate individual wave crest heights from ocean wave height data. So far i have selected the column of data that i want to look at and cut the data size down slightly. I think the next step is to use the sign function to get 1's, -1's and 0's from the data. Here's what I have so far:
>
> > >
>
> > >
>
> > >
>
> > > s=load('sample.txt');
>
> > >
>
> > > e1=s(:,9);
>
> > >
>
> > > eta1=e1(6000:end);
>
> > >
>
> > > sgn=sign(e1);
>
> > >
>
> > > ff=find(sgn==0);
>
> > >
>
> > >
>
> > >
>
> > > Does anyone know what i have to do next? Any help would be great!
>
> >
>
> > No, you need to find the points where the signs change:
>
> > t1=e1(1:end-1);
>
> > t2=e1(2:end);
>
> > tt=t1.*t2;
>
> > indx=find(tt<0);
>
> > Now, indx contains the locations of the zero crossings (upward and downward) as shown here:
>
> > t=[0:length(e1)-1]';
>
> > plot(t,e1,'b-',t(indx),e1(indx),'rx')
>
>
>
> Thats brilliant thanks! How is it now that i could select one of the zero crossing points (and in turn one wave) and calculate the crest height of the wave?


Throw away every second point:
indx=indx(1:2:end);
Set up a set of start and finish points;
k=[indx(1:end-1) indx(2:end)];
Now, wave number iwave has crest:
emx(iwave)=max(e1(k(iwave,1):k(iwave,2));
and wave height:
H(iwave)=max(e1(k(iwave,1):k(iwave,2)) - ...
min(e1(k(iwave,1):k(iwave,2));