필터 지우기
필터 지우기

How to create a chirp function in Matlab?

조회 수: 2 (최근 30일)
Sergio Campos
Sergio Campos 2017년 3월 2일
답변: Star Strider 2017년 3월 2일
In Matlab, I am amtempting to write a function that creates a chrip signal. I do not want to use the chirp function itself. I feel like I am missing something. My code is not working properly and I am not sure why. It does not alias correctly when it should and the sound does not change adjusting the frequency.
function [xx,tt]=mychirp(f1,f2,dur,fs)
%f1= starting frequency
%f2=end frequency
%fs=sampling frequency
tt=0:1/fs:dur; %Creates sampling window
m=(f2-f1)/(2*dur); %Calculating alpha/slope
s=2*pi*cos(m*tt.^2 +f1*tt);
soundsc(s,fs)
spectrogram(s,1024,[],1024,fs,'yaxis')
What am i missing here?

답변 (1개)

Star Strider
Star Strider 2017년 3월 2일
This creates ‘sort of’ chirp function:
[f1, f2, dur, fs] = deal(0, 1000, 2000, 8192);
tt=0:1/fs:dur; %Creates sampling window
m=(f2-f1)/(2*dur); %Calculating alpha/slope
s=2*pi*cos(m*tt.^2 +f1*tt);
soundsc(s,fs)
spectrogram(s,1024,[],1024,fs,'yaxis')
What do you want to create?

카테고리

Help CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by