# 通过声学多普勒效应测量汽车的速度

 In[2]:= XsampleRate = Quantity[8192, "Hertz"];

 In[3]:= Xcwt = ContinuousWaveletTransform[snd, GaborWavelet[24], {6, 24}];
 In[4]:= XWaveletScalogram[cwt, {2 | 3 | 4 | 5 | 6, _}]
 Out[4]=

 In[5]:= XsubsamplingFactor = sampleRate/Quantity[32, "Hertz"];
 In[6]:= XwaveletData2 = ArrayResample[ GaussianFilter[Abs@Map[First, cwt[All, "Values"]], Round[{{0, subsamplingFactor}, {0, subsamplingFactor/4}}]], {All, Scaled[1/subsamplingFactor]} ];

 In[7]:= XscaleShifts = Accumulate[Table[ FindPeaks[ ListCorrelate[waveletData2[[All, t]], ArrayPad[waveletData2[[All, t + 1]], 4, 0]], InterpolationOrder -> 3][[1, 1]] - 5, {t, 1, Last@Dimensions[waveletData2] - 2} ]];

 In[8]:= XscaleToFrequency[cwd_] := Evaluate[cwd["SampleRate"]/ cwd["WaveletScale"] 2^(-(#)/cwd["Voices"])] &;
 In[9]:= XfrequencyFactor = Normalize[scaleToFrequency[cwt][scaleShifts], Mean];
 In[10]:= XListLinePlot[frequencyFactor]
 Out[10]=

 In[11]:= Xnlm = NonlinearModelFit[frequencyFactor, 1 - ((t/32 - t0) v^2)/(343.2 Sqrt[d^2 + (t/32 - t0)^2 v^2]), {A, v, d, t0}, t]
 Out[11]=
 In[12]:= Xnlm["ParameterTable"] // Chop
 Out[12]=

 In[13]:= XUnitConvert[ Quantity[v /. nlm["BestFitParameters"], "Meters per seconds"], "km per hour"]
 Out[13]=

## Mathematica

Questions? Comments? Contact a Wolfram expert »