gpt4 book ai didi

matlab - 扫描/线性调频信号以不正确的频率结束

转载 作者:太空宇宙 更新时间:2023-11-03 20:35:20 29 4
gpt4 key购买 nike

我正在使用 matlab/octave 创建扫描/线性调频信号,我的结束信号似乎以错误的频率结束。我该如何修复它,以便信号以正确的频率结束。

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

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

%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

enter image description here

最佳答案

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

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

关于matlab - 扫描/线性调频信号以不正确的频率结束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21799697/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com