FFT of a row of data (for a beginner)
5 views (last 30 days)
Show older comments
Hello, I am an undergraduate student and I want to use the fft function to change a row of data points from the time domain to the frequency domain and then get the power spectrum. The row in question is a 1x600010 matrix of int16 type, taken from a 16x600010 int16 matrix. Right now my code is:
limits = [1 600010];
figure(1)
x = (1:600010);
y = double(Data(1,:))
plot(x,y,'r');
xlim(limits);
fs = 1000;
t = 0:1/fs:600010-1/fs;
m = length(y);
n = pow2(nextpow2(m));
Y = fft(y,n);
f = (0:n-1)*(fs/n);
power = Y.*conj(Y)/n
figure(2)
plot(f,power)
MATLAB says that there is an error in this line: Y = fft(y,n) because 'fft' is an undefined function for input arguments of type 'int16'. How do I change the type of the matrix for it to be compatible with the code, if possible?
0 Comments
Accepted Answer
Joseph Cheng
on 16 Nov 2015
Edited: Joseph Cheng
on 16 Nov 2015
convert the data using the function double()
y = double(Data(1,:))
you can read up on the different types of numbers and changing of types here: http://www.mathworks.com/help/matlab/numeric-types.html.
More Answers (0)
See Also
Categories
Find more on Fourier Analysis and Filtering in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!