【问题标题】:Sweep / chirp signal ends at incorrect frequency扫描/啁啾信号以不正确的频率结束
【发布时间】:2014-03-15 00:21:03
【问题描述】:

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

PS:我不能在 octave 中使用 chirp 命令,因为我正在使用特定方程式创建 chirp / 扫描信号。

带有简单等式的示例代码。和问题的情节

%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:我使用的是 octave 3.8.1

【问题讨论】:

  • 你犯了一个数学错误。如果您的波从 sin(0) 开始并在 sin(t*200) 结束,则总周期数是固定的并且平均对应于 200 hz,那么您所做的一切都是两者之间值的 x 位移。
  • @Daniel 谢谢,但我该如何解决这个问题?

标签: matlab signal-processing octave


【解决方案1】:

以下代码解释了如何生成频率可变的正弦波。

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));

【讨论】:

  • 你的代码有点混乱,你有几行 rem'd 以及 t 在需要之后被定义,除非那部分是因为某种原因被遗漏的。不,我没有符号工具箱
  • @RickT:这些行是函数句柄。在调用它们之前无需定义 t。
【解决方案2】:

Daniel's recipe之后,这是一个使用数值积分的版本,因此不需要符号工具箱:

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

t = 0:1/fs:dur;
freqt = linspace(freq1,freq2,numel(t));
ifreqt = cumsum(freqt)/fs;
data = sin(2*pi*ifreqt);
plot(t,data);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多