Home > voicebox > soundspeed.m

soundspeed

PURPOSE ^

SOUNDSPEED gives the speed of sound, density of air and acostuc impedance as a function of temp & pressure [V,D,Z]=(T,P,M,G)

SYNOPSIS ^

function [v,d,z]=soundspeed(t,p,m,g)

DESCRIPTION ^

SOUNDSPEED gives the speed of sound, density of air and acostuc impedance as a function of temp & pressure [V,D,Z]=(T,P,M,G)

  Inputs:  T        air temperature in Celsius  [20 deg C]
           P        air pressure [1 atm]
           M        average molecular weight of air [0.0289644 kg/mol]
           G        adiabatic constant for air [1.4]

 Outputs:  V        is the speed of sound in m/s
           D        density of air in kg/m^3
           Z        characteristic impedance of air Pa.s/m

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [v,d,z]=soundspeed(t,p,m,g)
0002 %SOUNDSPEED gives the speed of sound, density of air and acostuc impedance as a function of temp & pressure [V,D,Z]=(T,P,M,G)
0003 %
0004 %  Inputs:  T        air temperature in Celsius  [20 deg C]
0005 %           P        air pressure [1 atm]
0006 %           M        average molecular weight of air [0.0289644 kg/mol]
0007 %           G        adiabatic constant for air [1.4]
0008 %
0009 % Outputs:  V        is the speed of sound in m/s
0010 %           D        density of air in kg/m^3
0011 %           Z        characteristic impedance of air Pa.s/m
0012 
0013 % Notes: (1) Sound pressure is often measured in dB (SPL) relative to 20uPa [20*log10(p/p0)]
0014 %            Sound pressure is inversely proportional to distance.
0015 %        (2) Sound intensity is often measured indB relative to pW/m^2,[10*log10(J*10^12)]
0016 %            Intensity is inversely proportional to distance squared.
0017 %        (3) Intensity * impedance = pressure^2, so with the default values, 1 pW/m^2 = 20.33 uPa
0018 %            So: X dB (SPL) = X-93.98 dB (Pa) = X-0.14 dB (pW/m^2) =  X-120.14 dB (W/m^2)
0019 %        (4) The default air pressure (which does not affect sound speed) in various units is:
0020 %            1 atm = 101325 Pa = 1.01325 bar = 1.0332 at = 760 torr = 14.696 psi
0021 
0022 %       Copyright (C) Mike Brookes 2006
0023 %      Version: $Id: soundspeed.m 713 2011-10-16 14:45:43Z dmb $
0024 %
0025 %   VOICEBOX is a MATLAB toolbox for speech processing.
0026 %   Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html
0027 %
0028 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0029 %   This program is free software; you can redistribute it and/or modify
0030 %   it under the terms of the GNU General Public License as published by
0031 %   the Free Software Foundation; either version 2 of the License, or
0032 %   (at your option) any later version.
0033 %
0034 %   This program is distributed in the hope that it will be useful,
0035 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0036 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0037 %   GNU General Public License for more details.
0038 %
0039 %   You can obtain a copy of the GNU General Public License from
0040 %   http://www.gnu.org/copyleft/gpl.html or by writing to
0041 %   Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA.
0042 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0043 
0044 if nargin<4
0045     g=1.4;
0046     if nargin<3
0047         m=0.0289644;      % gm/mol
0048         if nargin<2
0049             p=1;
0050             if nargin<1
0051                 t=20;
0052             end
0053         end
0054     end
0055 end
0056 p=p*101325; % convert pressure: atm to pascal
0057 k=t+273.15;  % absolute temperature
0058 r=8.3144;  % J/(mol K) universal gas constant
0059 d=p*m/(r*k);
0060 v=sqrt(g*r*k/m);
0061 z=v*d;

Generated on Thu 02-Feb-2012 09:15:04 by m2html © 2003