Skip to content
Snippets Groups Projects
calculateSoundVelocity.m 1.2 KiB
Newer Older
function [calculatedSoundVelocity] = calculateSoundVelocity(pTemperature, pPressure, pMethod)
%CALCULATESOUNDVELOCITY Calculates the sound velocity based on the given values.
%   Parameters:
%       pTemperature    The temperature array.
%       pPressure       The pressure array.
%       pMethod         The chosen method. Available methods are:
%                       del grosso
%                       linear
%                       soundsource
%       pSoundSource    The sound source data. Only required if pMethod is
%                       set to soundsource.
%
%   Returns:
%       The calculated sound velocity in m/s.

switch lower(pMethod) % del grosso is default
    case 'linear'
        indices = (pTemperature > 0 & pTemperature < 20);
        meanTemperature = mean(pTemperature(indices));
        if meanTemperature > 0
            calculatedSoundVelocity = (meanTemperature - 7) * 0.0011 + 1490;
        else
            calculatedSoundVelocity = 1490;
        end
        clear indices;
    otherwise
        calculatedSoundVelocity = artoa.vendor.oceanstoolbox.sndspd( ...
leprob001's avatar
leprob001 committed
            35, mean(pTemperature(~isnan(pTemperature))), mean(pPressure(~isnan(pPressure))), 'del grosso' ...