CO2SYS for MATLAB updated to v1.1

An update of CO2SYS for MATLAB has been uploaded to CDIAC at

Several improvements to the previously available version have been made (see below), while retaining syntax compatibility.

Hopefully this is of use to many of you.

Best wishes,
Steven, Denis, James, Ernie, Doug.

So what’s new?

CO2SYS version 1.1 (Sept 2011).
Changes since 1.01 (June 2009):
– Added the outputting of K values
– Implementation of constants of Cai and Wang, 1998
– Implementation of constants of Lueker et al., 2000
– Implementation of constants of Mojica-Prieto and Millero, 2002
– Implementation of constants of Millero et al., 2002 (only their eqs. 19, 20, no TCO2 dependency)
– Implementation of constants of Millero et al., 2006
– Implementation of constants of Millero et al., 2010
– Properly listed Sal and Temp limits for the available constants
– Added switch for using the new Lee et al., (2010) formulation of Total Borate.
– Minor corrections to the GEOSECS constants (gave NaN for some output in earlier version)
– Fixed decimal point error on [H+] (did not get converted to umol/kgSW from mol/kgSW).
– Changed ‘Hfreein’ to ‘Hfreeout’ in the ‘NICEHEADERS’-output (typo)
– Function cleans up its global variables when done (if you loose variables, this may be the cause — see around line 570)

This is a MATLAB-version of the original CO2SYS for DOS. CO2SYS calculates and returns a detailed state of the carbonate system of oceanographic water samples, if supplied with enough input. Use this function as you would use any other Matlab inline function, i.e., a=func(b,c). For extended details on using the function, please refer to the enclosed help by typing “help CO2SYS” in Matlab. For details on the internal workings of the function, please refer to the original publication of Lewis and Wallace at Note that this function allows for the input of vectors. This means that you can calculate many samples at once. Each of these samples can be processed with individual salinities, temperatures, pH scales, dissociation constants, etc.

Original version for DOS was written by Lewis and Wallace. This was converted to MATLAB by Denis Pierrot at CIMAS, University of Miami, Miami, Florida. Vectorization, internal refinements and speed improvements were added by Steven van Heuven, University of Groningen, The Netherlands. Although functionality has been added, the output of the function has not changed. All versions of co2sys available at CDIAC (DOS, Excel for WINDOWS, Excel for MAC, MATLAB) should yield (near-) identical results when supplied with identical input. If you discover that they don’t or you have a more general bug report, please email me, Denis Pierrot or Alex Kozyr ( , , ).

Download the m-file “CO2SYS.m” and, optionally, the two examples. Place the file(s) in a location that Matlab can see (or add the location of the file(s) to Matlab’s search path). Run either of the examples in Matlab, or start using the main routine straight away.

van Heuven, S., D. Pierrot, J.W.B. Rae, E. Lewis, and D.W.R. Wallace. 2011. MATLAB Program Developed for CO2 System Calculations. ORNL/CDIAC-105b. Carbon Dioxide Information Analysis Center, Oak Ridge National Laboratory, U.S. Department of Energy, Oak Ridge, Tennessee. doi:10.3334/CDIAC/otg.CO2SYS_MATLAB_v1.1

  • Reset


OA-ICC Highlights

%d bloggers like this: