当前位置:网站首页>[matlab project practice] sine sweep (sine sweep signal)

[matlab project practice] sine sweep (sine sweep signal)

2022-07-23 07:05:00 Big peach Technology

It was written by a blogger python Code , I'll change it here to matlab 了

clc;clear all;
samplingrate = 44100;
sweeptime = 1;
f0 = 20;
f1 = 200;
peak = 1;
data=sinesweep(f0, f1, sweeptime, samplingrate, peak);
figure(1)
plot(data)

function

function data=sinesweep(f0, f1, sweeptime, samplingrate, peak)
%  Sweep signal : Starting frequency f0、 Cut off frequency f1、 Sampling rate and amplitude 
k = exp(log(f1 / f0) / sweeptime); %  Growth coefficient k Calculation formula 
data_len = sweeptime * samplingrate; %  Data length 
data = zeros(data_len,1);%  Create a data length of all 0 Of int Type array , It is used to store the amplitude value of each sampling point 
dt = 1.0 / samplingrate; %  Time interval between two sampling points 
t = 0; %  Starting time 
p = 2 * pi * f0 / log(k);
for i=1:data_len
    data(i) = peak * sin(p * (k^t - 1));%  Store the amplitude value of each sampling point into the array 
    t = t+dt; %  Add a time interval each time 
end

 Insert picture description here

Code link :https://download.csdn.net/download/qq_45047246/86245523

原网站

版权声明
本文为[Big peach Technology]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/204/202207221922337148.html