Is it possible to find the frequency specture from a signal imported from data points (excel)

조회 수: 3 (최근 30일)
Hi
I measured a signal with a lot of disturbance. The data was exported to excel and i had imported the data in Matlab and made a plot. Now i want to create a frequency plot. (where i can see the power of each frequency, to see which frequencies are wrong in the signal. I tried to use fft and ifft but with no results.
Do you have suggestions?
Thanks in advance
Lucas

채택된 답변

Mathieu NOE
Mathieu NOE 2020년 11월 3일
hello
for your help see my little demo below for audio wav file analysis. Just adapt the load to your data file format
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% signal
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% [signal,Fs]=wavread('audio_in_noise1.wav'); %(older matlab)
% or
[data,Fs]=audioread('audio_in_noise1.wav'); %(newer matlab)
channel = 1;
signal = data(:,channel);
samples = length(signal);
dt = 1/Fs;
t = (0:dt:(samples-1)*dt);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% FFT parameters
samples = length(signal);
NFFT = 512*4; %
NOVERLAP = round(0.75*NFFT);
w = hanning(NFFT);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% display 1 : averaged FFT spectrum
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[sensor_spectrum, freq] = pwelch(signal,w,NOVERLAP,NFFT,Fs);
figure(1),semilogx(freq,20*log10(sensor_spectrum));grid
title(['Averaged FFT Spectrum / Fs = ' num2str(Fs) ' Hz / Delta f = ' num2str(freq(2)-freq(1)) ' Hz ']);
xlabel('Frequency (Hz)');ylabel('Amplitude (dB)');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% display 2 : time / frequency analysis : spectrogram demo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
saturation_dB = 80; % dB range scale (means , the lowest displayed level is 80 dB below the max level)
[sg,fsg,tsg] = specgram(signal,NFFT,Fs,w,NOVERLAP);
% FFT normalisation and conversion amplitude from linear to dB peak
sg_dBpeak = 20*log10(abs(sg))+20*log10(2/length(fsg)); % NB : X=fft(x.*hanning(N))*4/N; % hanning only
% saturation to given dB range
mini_dB = round(max(max(sg_dBpeak))) - saturation_dB;
sg_dBpeak(sg_dBpeak<mini_dB) = mini_dB;
% plots spectrogram
figure(2);
imagesc(tsg,fsg,sg_dBpeak);axis('xy');colorbar('vert');grid
title(['Spectrogram / Fs = ' num2str(Fs) ' Hz / Delta f = ' num2str(fsg(2)-fsg(1)) ' Hz ']);
xlabel('Time (s)');ylabel('Frequency (Hz)');
  댓글 수: 2
Cavalle
Cavalle 2020년 11월 3일
Thanks a lot!
I wondered if there is a function simular like pwelch to create the FFT Spectrum graph (Display 1) (out of interest).
Greetings
Lucas Cornette
Mathieu NOE
Mathieu NOE 2020년 11월 3일
hello
sure, you could make your own code based on fft, but as pwelch is already available....
have fun !

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by