how can I change my time so that it takes frequency 1/250 hz
Show older comments
clc
clear all
close all
C = readtable('G2_adolescent.txt', 'NumHeaderLines',8);
%Convert to SI Units
accG2test = C{:,1}.*9.81;
forceG2test = C{:,2}.*0.00981;
dispG2test = C{:,3}./1000;
% time = dispG2test./accG2test;
forceG2test2 = smoothdata(forceG2test, 'sgolay', 100);
% Valleys Of Smoothed Data
[Vlys,vlocs] = findpeaks(-forceG2test2, 'MinPeakProminence',0.5);
Vlys = [-forceG2test2(1); Vlys];
vlocs = [1;vlocs];
% Sampling Interval
Ts = 1;
t = 1:height(C);
figure
plot(t, forceG2test2)
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:Force Vs Time (Cycles)');
legend('1','2','3','4','5','6','7','8','9');
xlabel('Time[sec]');
ylabel('Force[N]');
2 Comments
Star Strider
on 20 Oct 2021
Missing: 'G2_adolescent.txt'
Image Analyst
on 20 Oct 2021
I'm not sure what the question means "how can I change my time so that it takes frequency 1/250 hz". How does a time "take" a frequency? A frequency of (1/250) Hz means the period is 250 seconds. Do you want the x axis to go from 0 seconds to 250 seconds?
Accepted Answer
More Answers (0)
Categories
Find more on Design Condition Indicators Interactively in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

