sin信号とcos信号のfftの位相出力をテストしています。以下のスクリプトは信号を作成し、FFT を実行します。信号の位相のみに関心があるため、振幅がしきい値を下回るビンは、位相スペクトルに対してゼロになります。
% 10khz 10 second long time interval
t = 0:1 / 10000:10;
%1khz cos
c = cos(2 * pi * 1000 .* t);
%1khz sin
s = sin(2 * pi * 1000 .* t);
%ffts
C = fft(c)/length(c);
S = fft(s)/length(s);
%magnitude and phases of ffts
CA = abs(C); %cos magnitude
SA = abs(S); %sin magnitude
Cthresh = max(CA) * 0.5;
Sthresh = max(SA) * 0.5;
%find all indeces below the threshold
Crange = find(CA < Cthresh);
Srange = find(SA < Sthresh);
%set the indeces below the threshold to 0 - phase will be meaningless for
%noise values
CP = angle(C);
CP(Crange) = 0;
SP = angle(S);
SP(Srange) = 0;
CP (cos の位相) をプロットすると、cos 信号の周波数に対応するビンで 0.3142 の位相が得られ、他の場所ではゼロになります。これは pi/10 です。円周率を期待しています。どうしてこれなの?
SP をプロットすると、1.2566 の値が得られます。私は pi/2 または 1.5708 を期待しています。期待値の80%。これらのエラーの原因は何ですか?