Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Zero Crossing
Replies: 1   Last Post: Jan 28, 2013 2:14 PM

 Derek Goring Posts: 3,922 Registered: 12/7/04
Re: Zero Crossing
Posted: Jan 28, 2013 2:14 PM

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:
>
>
>
>
> 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')