フィルターのクリア

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

8 ビュー (過去 30 日間)
Merkhav E
Merkhav E 2020 年 8 月 16 日
コメント済み: Star Strider 2021 年 3 月 5 日
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 件のコメント
Merkhav E
Merkhav E 2020 年 8 月 18 日
Excellent. Thanks for your help.
Star Strider
Star Strider 2020 年 8 月 18 日
As always, my pleasure!

サインインしてコメントする。

採用された回答

Star Strider
Star Strider 2020 年 8 月 16 日
編集済み: Star Strider 2020 年 8 月 16 日
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 件のコメント
Merkhav E
Merkhav E 2021 年 3 月 5 日
Thank you for your help. It looks better now.
Star Strider
Star Strider 2021 年 3 月 5 日
As always, my pleasure!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpectral Measurements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by