How do I extract only the rows from a matrix that meet a specific requirement?
조회 수: 2 (최근 30일)
이전 댓글 표시
I have some matrixes containing the movement of certain subjects doing the same task, all of them of different length (some people take more time and some less). However, I need to compare them therefore the matrixes have to be same length. Since the matrixes have 4 columns, where first three are x y z and forth is time, I converted time in % of the cycle (since i know first and last row of each matrix correspond to start and end of a task). Now I have something like:
0.473487217592520 0.472650945192777 0.0963353018423272 0
0.451556907216931 0.493711477180010 0.104843749333787 0.116660590594240
0.428662781457986 0.515192918720937 0.114246578015789 0.233321181188480
0.403546122766580 0.537143904136897 0.126402289179415 0.360918702150930
My idea is to get a new matrix where I extract the row of data where time(% cicle) is close to 0.5, 1, 1.5, 2 and so on, so that from every initial matrix of data I get a new matrix with same length and correspond to same % of the cycle not depending on time. How can I extract only these data?
I know this isn't for sure the smartest way, I appreciate any suggestion or solving ways you have! Thank you!
댓글 수: 0
채택된 답변
Star Strider
2022년 2월 19일
‘My idea is to get a new matrix where I extract the row of data where time(% cicle) is close to 0.5, 1, 1.5, 2 and so on ...’
Assuming that ‘0.5’ is ‘0.5%’ (and so for the rest) —
M = [0.473487217592520 0.472650945192777 0.0963353018423272 0
0.451556907216931 0.493711477180010 0.104843749333787 0.116660590594240
0.428662781457986 0.515192918720937 0.114246578015789 0.233321181188480
0.403546122766580 0.537143904136897 0.126402289179415 0.360918702150930];
M4q = 0:0.005:1;
Mi = [interp1(M(:,4), M(:,1:3), M4q(:)) M4q(:)]
If I interpreted your request correctly, that should be the desired result.
.
댓글 수: 2
Star Strider
2022년 2월 20일
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!