File Exchange

image thumbnail

Tidal fitting toolbox

version 1.3 (422 KB) by Aslak Grinsted
fit tidal components to an observed series of sea level and use them for prediction


Updated 15 Dec 2014

View License

* Fitting of tidemodels to e.g. sea level data.
* Predictions of tide based on tide model.
Uses familar syntax from polyfit/polyval: tidalfit/tidalval

% TIDALFIT: Fits a tidal model to data

tidalfit uses the HAMELS (ordinary least squares)
technique to fit tidal components to the detrended data. Additionally it
can also do robust fitting.

Please include an acknowledgement to Aslak Grinsted if you use this code.

USAGE: tidal=tidalfit(data[,parameter,value])

data: A two column vector.
\ - first column should be a serial date number (See help datenum)
\ - second column should be the y-values (i.e. sea level)
\ (missing values and nans are OK.)

Components: cell-array of strings with names of the which
\ components should be included in the fit? (ALL is default)
\ Note: The routine will only attempt to fit components
\ that have period<data_timespan/4 and period>dt*2.
FittingMethod: 'OLS' for ordinary least squares or 'ROBUST' for robustfitting.
\ (default=OLS)
RobustFitOptions: cell of options for robustfit. (See help robustfit.)
\ only used if FittingMethod='ROBUST'. (default={})
DetrendData: should the data be detrended prior to fitting? (default=true)

Note: optional parameters can be specified using abbreviations. e.g. RFO for RobustFitOptions.

If no output arguments are specified the routine will display the results

tidal: A struct-array containing the fitted model parameters.
\ .name: name of tidal component (see e.g.
\ .period:period of tidal component in days
\ .speed: frequency of tidal component in degrees per solar hour
\ .amp: amplitude of fitted component
\ .phase: phase of fitted component

Components that are not included in the fit will have NaN in .amp and .phase.


Cite As

Aslak Grinsted (2021). Tidal fitting toolbox (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R14
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!