扫描/啁啾信号以不正确的频率结束 [英] Sweep / chirp signal ends at incorrect frequency

查看:24
本文介绍了扫描/啁啾信号以不正确的频率结束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 matlab/octave 创建一个扫描/啁啾信号,而我的结束信号似乎以错误的频率结束.如何修复它以便信号以正确的频率结束.

I'm creating a sweep / chirp signal using matlab / octave and my ending signal seems to be ending at the wrong frequency. How can I fix it so that the signal ends at the correct frequency.

PS:我无法在八度音程中使用 chirp 命令,因为我正在使用特定方程创建 chirp/sweep 信号.

PS: I can't use the chirp command in octave because I'm creating a chirp / sweep signal using a specific equation.

带有简单方程的示例代码.和问题图

Example code with simple equation. and plot of problem

%test sweep / chirp

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)

PS:我使用的是八度音程 3.8.1

PS: I'm using octave 3.8.1

推荐答案

以下代码解释了如何生成变频正弦波.

The following code explains how to generate a frequency-variable sin wave.

freq1=20; %start freq
freq2=200; %end freq
dur=1; %duration of signal in seconds


freq=@(t)freq1+(freq2-freq1)/dur*t;
%another example, may help to understand the code
%dur=2
%freq=@(t)heaviside(t-1)*10+heaviside(t-1.5)*-9;
%Integerate over the time-local frequency, gives the average frequency until t which later on gives the sin with the right phase
%In case you don't have symbolic toolbox, integrate manually. For the given numbers Ifreq=@(x)x.*(x.*9.0+2.0)
Ifreq=matlabFunction(int(freq(sym('x'))));
%Defining wave function based on `Ifreq`
wave=@(t)(sin(Ifreq(t)*2*pi));
t=0:.00001:dur;
plot(t,wave(t));

这篇关于扫描/啁啾信号以不正确的频率结束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆