Azzera filtri
Azzera filtri

How to find the frequency from data measured with a strain gage?

8 visualizzazioni (ultimi 30 giorni)
Hi,
I have collected data from a strain gage using a DAQ. I would like to find the frequency from that data.
I set the DAQ sample rate to 1000 samples per second, and I have 43800 samples. I am not sure if the sample rate is adequate and if the code below is correct to find the frequency.
If anyone has worked with this kind of test before and could help me to find the best approach to solve this problem.
Thank you,
signal = load('DataSG.txt');
N=length(signal);
Fs=1000; %Sampling frequency
Ts=1/Fs; %sampling period or time step
dt=0:Ts:43.8-Ts; %signal duration
X_mags = abs(fftshift(fft(signal)));
X_mags = X_mags/max(X_mags);
bin_vals = [0 : N-1];
N_2 = ceil(N/2);
fax_Hz = (bin_vals-N_2)*Fs/N;
subplot(2,1,1);
plot(dt,signal);
xlabel('Time[s]');
ylabel('Amplitude');
title('Time Domain Signal');
subplot(2,1,2);
plot(fax_Hz,X_mags);
xlabel ('Frequency [Hz]');
ylabel ('Normalized Amplitude');
title('frequency Domain Signal');
[B,IX] = sort(2*X_mags); %order the amplitudes
A1=B(end); %amplitude of the first peak
A2=B(end-1); %amplitude of second peak
f1=fax_Hz(IX(end)); %frequency of first peak
f2=fax_Hz(IX(end-1)); %frequency of second peak
BFloor=0.1; %BFloor is the minimum amplitude value (ignore small values)
Amplitudes=B(B>=BFloor) %find all amplitudes above the BFloor
Frequencies=fax_Hz(IX(1+end-numel(Amplitudes):end)) %frequency of the peaks

Risposta accettata

Star Strider
Star Strider il 16 Ago 2020
Modificato: Star Strider il 16 Ago 2020
Try this:
SG = load('DataSG.txt');
L = numel(SG);
Fs = 1E+3; % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
Ts = 1/Fs;
t = linspace(0, L, L)*Ts;
figure
plot(t, SG)
grid
SGm = SG - mean (SG); % Subtract Mean (D-C Offset) To Make Other Peaks More Visible
FTSG = fft(SGm)/L; % Fourier Transform
Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector
Iv = 1:numel(Fv); % Index Vector
[pks,lcs,w,p] = findpeaks(abs(FTSG(Iv))*2, 'MinPeakProminence',3, 'MinPeakDist',10);
[maxamp,idx] = max(abs(FTSG(Iv))*2);
figure
plot(Fv, abs(FTSG(Iv))*2)
hold on
plot(Fv(lcs), abs(FTSG(Iv(lcs)))*2, '^r')
hold off
grid
xlim([0 50])
text(Fv(idx),maxamp, sprintf('\\leftarrowAmplitude = %.3f\n Frequency = %.3f Hz', maxamp, Fv(idx)), 'HorizontalAlignment','left', 'VerticalAlignment','top')
It plots the peak frequency and significant harmonics.
Experiment with it to get the result you want.
EDIT — (16 Aug 2020 at 16:38)
Added plot image —
.
  4 Commenti

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by