File Exchange

image thumbnail

"UTide" Unified Tidal Analysis and Prediction Functions

version 1.0 (387 KB) by

Sea level & vector current; irregular times; confidence intervals; constituent selection diagnostics



View License

[ If you have questions, instead of leaving a note in "comments and ratings" below, please contact me at ]
Unified Tidal Analysis and Prediction Using the “UTide” Matlab Functions

* Designed specifically to handle record times that are irregularly distributed and/or gappy.

* Suitable for multi-year analyses: accurate nodal/satellite corrections are not limited to record lengths shorter than 1-2 years.

* Can provide easy-to-use and comprehensive diagnostics to aid the constituent selection process.

* Handles sea level (amplitude and phase), or currents (current ellipse parameters), with similar syntax.

* Generates confidence intervals based on spectra (FFT for regular times, Lomb-Scargle for irregular times) of the residuals between the raw input and the harmonic fit.

* Incorporates the robust L1/L2 solution method to minimize influence of outliers.

* Enables analysis of groups of time sequences (such as records from an array of instruments, or from a group of model gridpoints) with one m-function call.

* Builds on, and integrates in to a common framework, the t_tide (Pawlowicz et al 2002), r_t_tide (Leffler and Jay 2009), and "versatile" (Foreman et al 2009) approaches.

* Flexible interface with mix-and-match choices of analysis configurations accessible by arguments to m-functions.

* Download the m-files together with the technical report / user’s manual describing them here:

Technical Report / User’s Manual:
Codiga, D.L., 2011. Unified Tidal Analysis and Prediction Using the UTide Matlab Functions. Technical Report 2011-01. Graduate School of Oceanography, University of Rhode Island, Narragansett, RI. 59pp.

Also note:

1. The file, containing the m-files, is also available at ResarchGate (

2. For a python adaptation see:

Comments and Ratings (13)

Daniel Codiga

Hi Yi Fei Zhao,
Your error is in the confidence interval calculation and your call to ut_solv() is using the default method for calculation of confidence intervals (based on Monte Carlo and spectral residuals). This can happen for various reasons depending on the details of the dataset (irregular times or not, tidal signal to noise, etc. My first suggestion is for you to instead try the linearized method (add parameter 'LinCI') and/or the white spectral assumption (add parameter 'White'), for the confidence interval calculations-- unless you have specific reasons not to. This should clear up your problem. In addition you may want to use the ordinary least squares method (parameter 'OLS') instead of the default robust solver. These issues are all explained in the Technical Report. I have other suggestions as well, for example if you still want to get the Monet Carlo spectral residuals method (default) for confidence intervals to work--but if that would be helpful it will be best if you contact me directly by email at to continue the conversation.
Good luck,

Yi Fei Zhao

Hi, I want to run ut_solv(tin,uin,vin,lat,cnstit,varargin) with u_raw and v_raw, but it appears the error:
>> ut_solv(TIME,u1,v1,40.23,'auto')
ut_solv: matrix prep ... sol'n ... conf. int'vls ... wrong usage eig
EIG input can not contain NaN or Inf。

Error: ut_solv>ut_nearposdef (line 2463)
if all(eig(cov)>=0)

Error: ut_solv>ut_solv1 (line 1092)
varcov_mCc(c,:,:) = ut_nearposdef(squeeze(...

Error: ut_solv (line 382)
coef = ut_solv1(tin,uin,vin,lat,cnstit,varargin{:});
Both u and v are real, and the same size with TIME. I have no idea how to deal with it, can you help me?
Thank you!!!

Daniel Codiga

Hi Tomi
Please read section III B on page 39 of the Technical Report. It tells you specifically what other parts of the report to read first, in order to get going the fastest. An concise introduction to the syntax is given in section III C on page 40. If you have additional questions email me at
Good luck,

Tomi Aris

anybody help me give an easy tutorial using utide?
i'm sorry i don't know what should i do to use t-tide,.. i need it for my research

Daniel Codiga

prashanth J -- It seems your copy of ut_solv may have somehow become corrupted? I suggest downloading a fresh copy.

skykeithtr -- The first three inputs to ut_solv are t, u, and v. In the case of sea level data, one passes in t, u, and []. Try the command coef = ut_solv(t_raw,sl_raw,[],lat,'auto') instead of your "coef = ut_solv ( t_raw, sl_raw, lat, 'auto' );"

prashanth J

Hi, When I try to run ut_solv command I am getting following error.

coef = ut_solv(t_raw,sl_raw,[],lat,'auto');

However,appears the error:

??? Error: File: ut_solv.m Line: 914 Column: 14
Expression or statement is incorrect--possibly unbalanced (, {, or

Anyone could help me??


I was using this code with my data:
"coef = ut_solv ( t_raw, sl_raw, lat, 'auto' );"
and it appears:
"Error using statrobustfit (line 21)
Not enough points to perform robust estimation."

The data length is 259 with a time interval of 9.9156 days. But it contains 95 points of NaNs in the t_raw.

Could somebody help me?
Thanks in advance

Ben Modra


Robert (view profile)

Excellent and easy-to-use functions with in-depth documentation. Particularly useful for analysis and forecasting tides using measurement data with gaps in the measurement.

Daniel Codiga

Hi Rita,

Thanks for sending the data, then helping troubleshoot this problem until we were able to confirm it was associated with using an older (~2005) Matlab version. I wrote UTide using a ~2010 Matlab version.

Glad you were able to use a 2012 version of Matlab, and get UTide to work for your project.


p.s. To others who have questions the best way to reach me is directly at, as opposed to posting your question here.


Rita (view profile)

I have the same error than Eva, when I try to do a sea-level analysis...
Anyone could hel me/us??


Eva (view profile)

I was trying to use this code with my data obtained from Vessel Mounted ADCP (with irregular intervals), in the way:



t= detenum vector
u=real component of velocity
v=imaginary component of velocity

However,appears the error:

??? Error: File: ut_solv.m Line: 914 Column: 14
Expression or statement is incorrect--possibly unbalanced (, {, or

Anyone could help me??
It would possible that I can't use the selection algorithm for some reason??

Thanks in advance



Added note about ResearchGate


Added link to python adaptation.


Direct contact info added

MATLAB Release
MATLAB 7.10 (R2010a)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video