フィルターのクリア

FFT gives different answers according to what axis its applied to

2 ビュー (過去 30 日間)
Robin
Robin 2015 年 2 月 20 日
編集済み: Guillaume 2015 年 2 月 20 日
I am seeing some behaviour with fft which I did not expect. It appears the output of the FFT depends on the axis to which it is applied.
In the following example - doing the FFT of the same data vector differs depending on whether you do fft, axis 1, data (100,1) compared to doing fft on axis 2 with the data shaped (1,100). I would expect these to be the same?
r = randn(100,1);
rf = fft(r);
rf1 = fft(r,[],1);
rt = r';
rtf = fft(rt,[],2);
sum(abs(rf-rf1))
sum(abs(rf-rtf'))
Even more worrying - ifft behaves the same way, so when reconstructing the original random array:
irf = ifft(rf);
irtf = ifft(rtf'); % this doesn't match irf
irtf2 = ifft(rtf,[],2); % this does match irf
Shouldn't irtf and irtf2 be the same? This seems quite dangerous to me - I thought it is standard to transpose data as required in Matlab and I would not expect to see differences in the output here.

採用された回答

Guillaume
Guillaume 2015 年 2 月 20 日
編集済み: Guillaume 2015 年 2 月 20 日
The results are the same. Your problem is with the usage of ' aka ctranspose which computes the conjugate transpose of the input, i.e. not only transpose the vector but returns the conjugate of complex values.
To just do a plain transpose use the dotted version .' aka transpose:
r = randn(100, 1);
isequal(fft(r), fft(r, [], 1)) %return true
isequal(fft(r), fft(r.', [], 2).') %return true
edit: d'oh. Got my demo wrong!

その他の回答 (1 件)

Thomas Koelen
Thomas Koelen 2015 年 2 月 20 日
編集済み: Thomas Koelen 2015 年 2 月 20 日
fft behaves the same in:
clc
close all
clear all
A=rand(1,100);
B=A';
X1=abs(fft(A));
X2=abs(fft(B));
figure(1)
plot(X1)
figure(2)
plot(X2)
Try this.

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by