Application of ifft function
1 回表示 (過去 30 日間)
古いコメントを表示
I'm trying to apply the inverse FFT function on a wave. I directly gave the velocity recorded signal ('v4b') as input in MATLAB and also its corresponding time vector ('t'). I have applied a filter and the FFT function to the original signal, then I need to come back to the time domain with the ifft function for obtaining the signal without noise. I have a problem in obtaining the inverse FFT because the length of the signal obtained is different from the length of time vector. Someone can help me? Thank you in advance!
Fs = 200;
b = fir1(8800, 1.3/(Fs/2));
load 't.txt';
load 'v4b.txt';
figure(1)
subplot(1,2,1);
plot(t,v4b);
axis([0 2 0 5]);
title('4 blocks, pos.1, setup2:Istantaneous velocity');
xlabel('Time [s]');
ylabel('Velocity [m/s]');
x = filter(b, 1, v4b);
l = length(x);
N = length(v4b);
X = fft(x);
X = X(1:N/2+1);
psdx = (1/(Fs*N))*abs(X).^2;
psdx(2:end-1) = 2*psdx(2:end-1);
freq = 0:Fs/l:Fs/2;
subplot(1,2,2);
loglog (freq,psdx);
title('4 blocks_pos.1_setup2: Power Spectral Density of the Signal');
xlabel('Frequency [Hz]');
ylabel('Power/Frequency [m^2/(Hz*s^2)]');
figure(2)
Y=ifft(X);
plot(t,Y);
After running the warning is: 'Error using plot. Vectors must be the same length.'
0 件のコメント
回答 (1 件)
Kushagr Gupta
2016 年 12 月 19 日
The error being received is expected as the lengths of variable 't' and 'Y' do not match.
After the line:
>> X = X(1:N/2+1)
is executed, length of 'X' becomes half of length of variables 'x' or 't' and when ifft is performed on 'X', the result 'Y' has same length as 'X' which is half of 't' and thus the error.
There are various ways to avoid this error and as the question asks for accessing the time domain values without noise, one way to do this would be taking the ifft of the vector 'x' instead of 'X'.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Transforms についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!