What changes are required in the code

clc
clear all
close all
C = readtable('G2_adult.txt', 'NumHeaderLines',8);
%Convert to SI Units
accG2test = C{:,1}.*9.81;
forceG2test = C{:,2}.*0.00981;
dispG2test = C{:,3}./1000;
% time = dispG2test./accG2test;
dispG2test2 = smoothdata(dispG2test, 'sgolay', 100);
% Valleys Of Smoothed Data
[Vlys,vlocs] = findpeaks(-dispG2test2, 'MinPeakProminence',0.5);
Vlys = [-dispG2test2(1); Vlys];
vlocs = [1;vlocs];
% Sampling Interval
Ts = 1;
t = 1:height(C);
figure
plot(t, dispG2test2)
hold on
plot(t(vlocs), -Vlys, '+r')
hold off
for k = 1:numel(vlocs)-1
% Index Range For This Segment
idx{k} = vlocs(k):vlocs(k+1);
% Time Vector
tc{k} = t(idx{k});
% Signal Segment
sc{k} = forceG2test(idx{k});
end
% Maximum Segment Length
tcmax = max(cellfun(@numel,tc));
% Preallocate
ensb = zeros(tcmax,numel(idx));
for k = 1:numel(idx)
% Create 'Ensemble'
ensb(1:numel(idx{k}),k) = sc{k};
end
figure
% Plot Ensemble
plot(1:tcmax, ensb)
title ('C:Diflection Vs Time (Cycles)');
xlabel('Time[sec]');
ylabel('Diflection[m]');
Please Refer the attached .txt file for the data

7 件のコメント

Manav Divekar
Manav Divekar 2021 年 10 月 19 日
not giving accurate results
Star Strider
Star Strider 2021 年 10 月 19 日
My answer was never followed up, and the signal to be analysed was never clarified.
Nevertheless,. my code in my un-accepted answer appears here without attribution.
This is just wrong.
Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021 年 10 月 19 日
In addition to what Start Strider has propsed in his complete answer code, you can apply some sort of moving average smoothing filter, e.g.: smoothdata() to get rid of the jagged plotted points as shown in the answer code of Star Strider. Note that what Star Strider has proposed is a complete code.
Star Strider
Star Strider 2021 年 10 月 19 日
@Sulaymon Eshkabilov Thank you!
Manav Divekar
Manav Divekar 2021 年 10 月 19 日
I am sorry I accepted your answer, i forgot to click it.
Star Strider
Star Strider 2021 年 10 月 19 日
@Manav DivekarThank you!

回答 (0 件)

この質問は閉じられています。

質問済み:

2021 年 10 月 19 日

閉鎖済み:

2021 年 10 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by