Wave Upward Zero Crossing Function
WaveUpZeroCrossing
==================
.. code:: MATLAB
[H,T,Time,UpCrossIndex,UpCrossTime,UpCrossValue,TroughTime,TroughValue,CrestTime,CrestValue]=WaveUpZeroCrossing(x,crosslevel,fs,dispout)
Description
-----------
| Detects upward zero crossing of a given wave signal
| The code only detects a full oscillation.
| If the first or the last wave does not have a full oscillation (based on upward zero crossing method), code ignores them.
| This is done to prevent wrong period detection for the very first or last wave.
| This function is a part of and modified from the ScientiMate packages.
| For more information visit: www.arashkarimpour.com and https://scientimate.readthedocs.io
Inputs
------
x
Input wave time series (oscillatory) data
crosslevel='zero';
| Define to remove mean from input data or not ('yes': remove, 'no': not remove)
| 'zero': crossing is calculated respect to zero
| 'mean': crossing is calculated respect to a mean of the data
fs=1;
| Sampling frequency that data collected at in (Hz)
| If fs is not given, then default fs is fs=1;
| If fs=1, then index of data points represents time as well
dispout='no';
Define to display outputs or not ('yes': display, 'no': not display)
Outputs
-------
H
Wave height data series with same unit as input
T
Wave period data series (second)
Time
Time (second)
UpCrossIndex
Index of up-crossing location
UpCrossTime
Time of up-crossing location
UpCrossValue
Value of up-crossing
TroughTime
Time of wave trough location
TroughValue
Value of wave trough
CrestTime
Time of wave crest location
CrestValue
Value of wave crest
Examples
--------
.. code:: MATLAB
fs=2; %Sampling frequency
duration=32; %Duration of the data
N=fs*duration; %Total number of points
dt=1/fs; %Time difference, dt=1/fs
t(:,1)=linspace(0,duration-dt,N); %Time
x(:,1)=0.1+(0.5.*cos(2*pi*0.2*t)+(-0.1+(0.1-(-0.1))).*rand(N,1));
[H,T,Time,UpCrossIndex,UpCrossTime,UpCrossValue,TroughTime,TroughValue,CrestTime,CrestValue]=WaveUpZeroCrossing(x,'zero',fs,'yes');
References
----------
* http://www.arashkarimpour.com
* https://scientimate.readthedocs.io
Cite As
Arash Karimpour (2026). Wave Upward Zero Crossing Function (https://nl.mathworks.com/matlabcentral/fileexchange/59342-wave-upward-zero-crossing-function), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
- Signal Processing > DSP System Toolbox > Signal Generation, Manipulation, and Analysis > Signal Operations >
Tags
Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
