how to use excel data in matlab for fast fourier transform?

Hi everybody
i have attached a excel file. In this file, the first column is my magnitute in micron. I have got 71 magnitude values and all recorded in 0.5 seconds.I would like to use FFT, to change from time domain into frequency domain.
Sampling frequency is 142.
Can anyone help me out how to do that?
Kind regards.

5 Kommentare

I tried the code below. My max magnitude in the excel file is over 4. I can not see this in my results. any help highly appreciated.
data = xlsread('Lateral_vibration.xlsx','sheet1','A1:A71');
time = 0:1;
signal = data(:,1);
L=length(signal); % Length of signal
Ts = mean(diff(time));
Fs = 1/Ts;
NFFT = 2^nextpow2(L); % Next power of 2 from length of y
Y = fft(signal,NFFT)/L;
frequency = -Fs/2+Fs/NFFT:Fs/NFFT:Fs/2;
Ycent = fftshift(Y);
figure;
subplot(2,2,1);
plot(frequency,abs(Ycent)); % Plot single-sided amplitude spectrum.
grid on
title('Single-Sided Amplitude Spectrum of y(t)');
xlabel('Frequency (Hz)');
ylabel('|Y(f)|');
Y1 = fft(signal,NFFT)*Ts;
Y1 = fftshift(Y);
subplot(2,2,2);
plot(frequency,abs(Y1));
grid on
title('Amplitude Spectrum of y(t)');
xlabel('Frequency (Hz)');
ylabel('|Y1(f)|');
subplot(2,2,3);
plot(frequency,angle(Y));
grid on
title('Phase of y(t)');
xlabel('Frequency (Hz)');
ylabel('Phase of Y(f)');
You've plotted the zero-centered power so half the signal energy is in each peak.
Also, the max amplitude in a time signal is only the same as the magnitude of the frequency spectrum if the energy content of the signal is a pure tone without noise and centered on a frequency bin. Otherwise, the total energy is spread across the frequencies in the signal and must integrate each peak to get its total energy.
Clearly, I was doing image processing. for each frame, I have got a corresponding magnitude of lateral vibration. In total , I have got 71 images, and the camera I use is capable of taking 200 images per second.The graph I have now is magnitude vs frame number. How can I convert this into magnitude vs frequency? Your idea is highly appreciated.
"Clearly, I was doing image processing. for each frame..."
I see nothing in the code that gives any clue whatsoever that that would have been so, certainly not "clearly".
Anyways, it's certainly not clear to me how an image relates to lateral vibration, but looks like you would have to build the data arrays to do the FFT across all the images--whether those are 2D or what isn't clear to me, certainly as you've got simply a vector above.
What is this the "magnitude" of?
I have attached the excel file that I am using, as well the code. I have got a data for lateral and axial vibration as in attached excel file. In my code, I plotted these vibration in time and frequency domain. I am not sure if I used FFT right to plot these vibration in frequency domain. The magnitude of vibration range is not the same in time and frequency domain. what could be the reason? There is a peak at the start of the graph for axial and lateral vibration in frequency domain. Can you please tell me how should interpret the graphs? are my plots correct?

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

dpb
dpb am 23 Mär. 2019
[V,H]=xlsread('Vibration_analysis_FFT.xlsx'); % read data
H % headers -- ok, says lateral, axial in first two column
T=mean(diff(V(:,3))) % sample rate.. 0.005 --> 5 ms
Fs=1/T; % sampling frequency, 200 Hz
L=length(V); % length of sample
t=(0:L-1)*T; % time vector -- not really needed
Y=fft(V(:,1:2)); % FFt the two accelerations
P2=abs(Y/L); % 2-sided PSD estimator
P1=P2(1:fix(L/2)+1,:); % 1-sided
P1(2:end-1)=2*P1(2:end-1); % (-)freq half the energy but only only one DC;Fmax bin
f=Fs*(0:fix(L/2))/L; % the frequency at 200 Hz for L points
figure
plot(f,P1)
Shows have mostly just a DC component (non-zero mean) whch, parenthetically, means the sensor must be moving somewhere...let's compensate for the mean and see if helps...don't think will a lot because there's still mostly just a 1/f rolloff, no real spectral content in the signal...untitled.jpg
Y=fft(V(:,1:2)-mean(V(:,1:2))); % remove mean before FFT
P2=abs(Y/L);
P1=P2(1:fix(L/2)+1,:);
figure
plot(f,P1)
untitled.jpg
As thought, just wipes the one commponent out, but leaves most other low frequency stuff. Try just a little more resolution by interpolationg since is very short signal...
N=128;
Y=fft(V(:,1:2)-mean(V(:,1:2)),N); % use 128-pt FFT
P2=abs(Y/L); % all the energy still in L time samples
P1=P2(1:fix(N/2)+1,:);
P1(2:end-1)=2*P1(2:end-1);
f=Fs*(0:fix(N/2))/N;
figure
plot(f,P1)
untitled.jpg
Shows a little more structure, maybe -- whether any of it is real is probably questionable I'd guess...what is the measurement of?

4 Kommentare

This is the measurement of a displacements for an object in micron size. Why the amplitudes are very low? is this expected?
dpb
dpb am 23 Mär. 2019
Bearbeitet: dpb am 23 Mär. 2019
Ah! It is displacement, not acceleration as I was thinking...same thing, though in that you're converting from the time domain into a frequency domain. Another way to think of that is it shows what is going on at a given rate.
For this set of signals, it's basically a translation with some hiccups in it and the bulk of the change is really very slow, hence the 1/f rolloff kind of general shape.
Again, all the energy is in the integral of the full PSD; it's also based on how one normalizes but the peak time history amplitude isn't ever going to be the same as the peak time history amplitude except, as noted before, a pure sinusoid whose frequency exactly also matches a frequency bin in the FFT.
If you plot your time histories, that max value of 4 exists for only one sample out of the full time history. That value would have to exist at a given frequency in the signal for the entire duration for that amplitude to show up on the frequency plot.
See the example under
doc fft
that shows that given known signal the normalization will, in fact, reproduce that amplitude.
A power normalization is in units of the measurement/Hz; to get an actual displacement over a given frequency you again have to integrate. But again, remember that's going to be at the frequency of that motion and that's not the same as the displacement at any particular point in time.
I don't really know/understand what/why you are looking at the frequency response??? What are you trying to learn by doing so?
Thanks for the answer. It is very informative. As I am doing vibrational analysis, I though FFT would help to understand the vibrational behaviour of my object. Instead of having displacements in x and y direction versus time, I thought would be more effective to see displacments versus frequency so that I can see at what amplitude what is the frequency? Therefore I was confused when I saw the amplitude range changed. What I wanna conclude from the graph is that what is the max displacement and at what frequency? Because, I thought even if I calculate the max amplitude in x and y direction, without frequency information, this graph would not be very informative. I hope I am on the right track.
dpb
dpb am 24 Mär. 2019
Bearbeitet: dpb am 24 Mär. 2019
Well, I don't know...without knowing a lot more about what you're measuring and what the objectives are, it's really hard to say anything concrete about the data itself other than "it is what it is".
Basically, it shows there was a translation measured which occurred mostly in one translation between sampling points very early and then another sorta' jerky ramp towards the middle and then one big jump in X at the end that was reversed to its starting point.
There really is very little indication of any real consistent frequency pattern in the motion and what there is looks to be mostly undersampled in that the excursions mostly are only one or two points along those events.
Add on to that, that you have an extremely short time series to work with, what estimation of any frequency components in the signal is pretty difficult to discern could be anything more than noise.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Gefragt:

am 22 Mär. 2019

Bearbeitet:

dpb
am 24 Mär. 2019

Community Treasure Hunt

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

Start Hunting!

Translated by