I'm trying to create a chirp/swept signal that has it's frequency going down exponentially using matlab/octave. I can't use the built in chirp function because I'm trying to create a chirp/swept signal based on an equation/formula. I tried creating some code below but as you see from the spectrogram the frequency does not end at the correct frequency, and the frequency doesn't go down exponentially.
clear all,clc freq1=20; %start freq freq2=200; %end freq fs=44100; dur=1; %duration of signal in seconds t = linspace(0,2*pi,fs*dur); f=freq1:(freq2-freq1)/length(t):freq2-(freq2-freq1)/length(t); %20:(200-20)/lenght(t) :200-(200-20)/length(t) data=sin(f.*t); %build signal data=(data/max(abs(data))*.8); %normalize signal wavwrite([data'] ,fs,32,strcat('/tmp/del.wav')); %export file plot(t,data)
Here's a spectrogram plot
1) create a signal based on a given equation/formula where the frequency is exponentially decaying (based on the formula 1/exp)
2) be able to type in the starting and ending frequency along with it's duration in seconds example startfreq=20; endfreq=200; durseconds=2;
The spectrogram plot should look something like this if the start frequency is 200hz ending at 20hz.