I have two column one is time column and another is speed column. The speed is constant but when a subject starts running the speed increase. I want to know the exact time point when a subject start run using a MATLAB code. I collected five trials in one file. I want to know the five time steps from one file. Attached is the excel sheet.

 채택된 답변

KSSV
KSSV 2016년 3월 4일

2 개 추천

clc; clear all ;
data = xlsread('Book1.xlsx') ; % Read the data
t = data(:,1) ; x = data(:,2) ; % Seperate columns
start_t = []; % Initialize needed time
start_idx = [] ; % Initialize needed indices
for i = 1:length(t)-1
dx = x(i+1)-x(i) ;
if dx ~=0 && dx == x(i+1)
start_idx = [start_idx ; i ] ;
start_t = [start_t ; t(i)] ;
end
end
plot(t,x) ;
hold on
plot(t(start_idx),x(start_idx),'.r') ;

추가 답변 (1개)

Jos (10584)
Jos (10584) 2016년 3월 4일

1 개 추천

Let S be your vector of speeds, and T your time points
% Determine, for each time point, is the subject running or not
IsRunning = S > 0 ;
% For each time point, did the subject change from not-running to running
TF = [false ; diff(IsRunning(:))==1] ;
% At what indices did this happen
index = find(TF)
% and the time points are:
T_startedToRun = T(index)
% check with a plot
plot(T,S,'b-', T_startedToRun,0,'rs') ;

카테고리

도움말 센터File Exchange에서 Parallel Computing Toolbox에 대해 자세히 알아보기

태그

질문:

2016년 3월 4일

댓글:

2016년 3월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by