how can I change my time so that it takes frequency 1/250 hz

9 ビュー (過去 30 日間)
Manav Divekar
Manav Divekar 2021 年 10 月 20 日
回答済み: Star Strider 2021 年 10 月 20 日
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 件のコメント
Star Strider
Star Strider 2021 年 10 月 20 日
Missing: 'G2_adolescent.txt'
Image Analyst
Image Analyst 2021 年 10 月 20 日
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?

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

採用された回答

Star Strider
Star Strider 2021 年 10 月 20 日
If is the sampling interval, multiply it by the sampling instants to convert them to time —
C = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/773388/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;
Ts = 1/250; % Define Sampling Interval
t = 1:height(C);
t = t * Ts; % Multiply 't' By 'Ts' To Convert Samples To Time
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(t(1:tcmax), ensb) % Subscript 't' To Show Time, Not Samples
% 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]');
.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeChristmas / Winter についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by