How to find the frequency from data measured with a strain gage?
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Merkhav E
el 16 de Ag. de 2020
Comentada: Star Strider
el 5 de Mzo. de 2021
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
2 comentarios
Respuesta aceptada
Star Strider
el 16 de Ag. de 2020
Editada: Star Strider
el 16 de Ag. de 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 —
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/346662/image.png)
.
4 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Spectral Measurements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!