How to divide the data of a matrix?

조회 수: 5 (최근 30일)
Abin Krishnan
Abin Krishnan 2014년 2월 13일
답변: Jos (10584) 2014년 2월 13일
I have a data in which the first column gives the time and the second column gives the velocity. The time varies from 0 to 0.8 seconds.I want to divide the time into groups starting from 0 to 0.1 s, 0.1 to 0.2 ..., 0.7 to 0.8 s.Then take the count of the velocity in the respective group.
  댓글 수: 2
Azzi Abdelmalek
Azzi Abdelmalek 2014년 2월 13일
Then take the count of the velocity in the respective group What does that mean?
Azzi Abdelmalek
Azzi Abdelmalek 2014년 2월 13일
You can give a short numeric example to explain what you want

댓글을 달려면 로그인하십시오.

답변 (1개)

Jos (10584)
Jos (10584) 2014년 2월 13일
TIMES = DATA(:,1) ;
VELS = DATA(:,2) ;
TakeTheCountOfTheVelocityFunction = @(V) numel(V) ; % or whatever you mean by this?
[n, GroupIDX] = histc(TIMES,0:0.1:0.8) ; % GroupIDX specifies the group
Result = accummarray(GroupIDX(:), VEL(:), TakeTheCountOfTheVelocityFunction)

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by