2014-02-15 40 views
2

我創建使用MATLAB /倍頻掃描/線性調頻信號結束,我的結束信號,似乎在錯誤的頻率接近尾聲。我該如何修復它,以便信號以正確的頻率結束。掃描/線性調頻脈衝信號不正確的頻率

PS:因爲我創建使用特定的方程式線性調頻/掃頻信號,我不能在八度使用啁啾命令。

實施例的代碼與簡單的等式。而問題的情節

%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

enter image description here

+0

你正在做一個數學錯誤。如果你的波開始於罪(0)和在SIN(噸* 200)結束的週期的總數目是固定的,並且對應於平均200赫茲,你做的一切是在之間的值的x偏移。 – Daniel

+0

@丹尼爾謝謝,但我該如何解決這個問題? –

回答

0

下面的代碼說明如何生成可變頻率正弦波。

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


[email protected](t)freq1+(freq2-freq1)/dur*t; 
%another example, may help to understand the code 
%dur=2 
%[email protected](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 [email protected](x)x.*(x.*9.0+2.0) 
Ifreq=matlabFunction(int(freq(sym('x')))); 
%Defining wave function based on `Ifreq` 
[email protected](t)(sin(Ifreq(t)*2*pi)); 
t=0:.00001:dur; 
plot(t,wave(t)); 
+0

你的代碼是有點混亂,你有幾行rem'd了與T一起被定義它的需要後,除非那部分被排除在外的一個原因。不,我沒有符號工具箱 –

+0

@RickT:這些行是函數句柄。在被調用之前不需要定義t。 – Daniel