OUTPUT: sound speed in m/s
This function allows any or all inputs to be scalar or vectors. However, dimensions of all vector inputs must agree.
T_degrees_C is temperature in [°C]
P_kPa is absolute pressure [kPa]
S_ppt is salinity in ppt; most often close enough to psu for practical purposes. For freshwater use S_ppt = 0 or leave blank
If you have data from a CTD cast, you might have values for temperature, pressure, and salinity in the following format. (These example values are entirely hypothetical):
T_profile = [22 22 21 19 18];
P_profile = [101 150 199 240 300];
S_profile = [35.5 35 34.5 34 34.5];
Or you might have constant values for one or all of the input parameters:
T_const = 22;
P_const = 110;
S_const = 33;
ANY OF THE INPUTS FOLLOWING WILL WORK:
d = 0:5000; % for depth of 0 to 5 kilometers
p = 101.325+1025*9.81*d/1000; % pressure equivalent in kPa
t = [20:-10/500:10 10*ones(1,4500)]; % a very simplified thermocline model
c = c_water(t,p,32);
xlabel('sound speed (m/s)')
Note: This calculator assumes a complete absence of bubbles. Even a small amount of gas in the water column may significantly affect sound speed. See Wood's model for the bulk sound speed of multiphase media.
Val: This is very helpful, thank you! I was not previously aware of the TEOS toolbox, but you're right--it is much more comprehensive and possibly more accurate than the file shared on this page.
Acknowledged the "raytrace" function by Val Schmidt.
Clarified the validity of this function as it relates to bubbles in the water column.
Any or all of the input values may now be arrays or constants.
Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.