File: doppler_spread.m

package info (click to toggle)
codec2 1.2.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 76,376 kB
  • sloc: ansic: 436,819; cpp: 2,091; objc: 1,736; sh: 1,510; python: 1,405; asm: 683; makefile: 605
file content (38 lines) | stat: -rw-r--r-- 1,059 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
% doppler_spread.m
% David Rowe Jan 2016
%
% Returns gausssian filtered doppler spreading function samples for HF channel
% modelling.  Used PathSim technical guide as a reference - thanks Moe!

function [spread_FsHz states] = doppler_spread(dopplerSpreadHz, FsHz, Nsam)

  % start with low Fs so we can work with a reasonable filter length

  sigma = dopplerSpreadHz/2;
  lowFs = ceil(10*dopplerSpreadHz);
  Ntaps = 100;
  Nsam_low = ceil(Nsam*lowFs/FsHz + Ntaps); % fill filter memory
  
  % generate gaussian freq response and design filter

  x = 0:lowFs/100:lowFs/2;
  y = (1/(sigma*sqrt(2*pi)))*exp(-(x.^2)/(2*sigma*sigma));
  b = fir2(Ntaps-1, x/(lowFs/2), y);
  
  % generate the spreading samples

  spread_lowFs = filter(b,1,randn(1,Nsam_low) + j*randn(1,Nsam_low));

  % resample to FsHz, scaling for desired spreadFreqHz

  spread_FsHz = resample(spread_lowFs(Ntaps+1:Nsam_low), FsHz, lowFs);
  assert(length(spread_FsHz) >= Nsam);
  
  % return some states for optional unit testing
  states.x = x;
  states.y = y;
  states.b = b;

endfunction