2014-02-15 1 views
2

matlab/octave를 사용하여 스윕/챠프 신호를 만들고 내 종료 신호가 잘못된 주파수로 끝나는 것처럼 보입니다. 신호가 올바른 주파수로 끝나도록 수정하는 방법은 무엇입니까?스윕/첩프 신호가 잘못된 주파수에서 끝납니다

추 신 : 특정 방정식을 사용하여 챠프/스윕 신호를 생성하기 때문에 옥타브에서 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 : 나는 옥타브 3.8.1

enter image description here

+0

수학 오류가 발생했습니다. 당신의 웨이브가 sin (0)에서 시작하여 sin (t * 200)에서 끝나는 경우 총 사이클 수는 고정되어 평균 200hz에 해당합니다. 그 사이의 값은 x- 시프트입니다. – Daniel

+0

@Daniel에 감사하지만 어떻게 해결할 수 있습니까? –

답변

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

코드가 다소 혼란 스럽습니다. 이유가있는 부분을 빠뜨리지 않으면 필요한 후에 여러 줄을 다시 정의해야합니다. 심볼릭 도구 상자가 없습니다. –

+0

@RickT :이 줄은 함수 핸들입니다. 호출되기 전에 t를 정의 할 필요가 없습니다. – Daniel

관련 문제