Skip to content

Commit b1daf98

Browse files
authored
Merge pull request #192 from baggepinnen/chirpfix
update chirp spectrum
2 parents b3ec8a3 + 0c48609 commit b1daf98

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎src/input_signals.jl‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,16 +126,21 @@ function chirp(N::Int; Ts::Real, f0::Real, f1::Real, logspace::Bool=true)
126126
end
127127

128128
t = range(0, step=Ts, length=N)
129+
T = t[end] - t[1]
129130

130131
f0 > 0 && f1 > 0 || throw(ArgumentError("f0 and f1 must be positive frequencies"))
131132

132133
if logspace
133-
f = exp10.(LinRange(log10(f0), log10(f1), N))
134+
f = f0 .* (f1/f0) .^ (t ./ T)
135+
phase = (2π * T / log(f1/f0)) .* (f .- f0)
134136
else
135137
f = LinRange(f0, f1, N)
138+
k = (f1 - f0) / T
139+
phase = 2π .* (f0 .* t .+ (k/2) .* t.^2)
136140
end
137141

138-
q = @. sin(2π * f * t)
142+
q = sin.(phase)
143+
139144
return q
140145
end
141146

0 commit comments

Comments
 (0)