Why does values of fft change when length changes?
Show older comments
Hi, I've got the following code-
x =[1,2,3,2];
y = [2,2,2,0,-4,4,4];
xlen = length(x);
ylen = length(y);
resultlength = xlen+ylen-1;
x1 = [x zeros(1,resultlength-xlen)];
y1 = [y zeros(1,resultlength-ylen)];
X = fft(x); Y=fft(y);
X1 = fft(x1); Y1=fft(y1);
X2 = fft(x,512); Y2 = fft(y,512);
% X2 = X2(1:10); Y2 = Y2(1:10);
freq1 = linspace(0,100,resultlength);
freq2 = linspace(0,100,512);
plot(freq1,abs(X1),'ro'); hold;
plot(freq2,abs(X2),'bo');
Shouldn't the blue plot and the red plot follow each other? Why are there values in the red plot that are not in the blue plot?
Thanks!
Accepted Answer
More Answers (0)
Categories
Find more on Spectral Measurements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!