Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


Math Forum » Discussions » Software » comp.soft-sys.matlab

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

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View  
Derek Goring

Posts: 3,919
Registered: 12/7/04
Re: Zero Crossing
Posted: Jan 28, 2013 2:14 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.