Tidal fitting toolbox

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. http://www.mhl.nsw.gov.au/www/tide_glossary.htmlx)
\ .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 (2024). Tidal fitting toolbox (https://www.mathworks.com/matlabcentral/fileexchange/19099-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!
Version Published Release Notes

added example html

mathworks didn't update the file correctly last time, so i have to re-upload it again. (It is still the old zip file but description has changed.)