フィルターのクリア

How do I extract only the rows from a matrix that meet a specific requirement?

3 ビュー (過去 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!

採用された回答

Star Strider
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(:)]
Mi = 201×4
0.4735 0.4727 0.0963 0 0.4725 0.4736 0.0967 0.0050 0.4716 0.4745 0.0971 0.0100 0.4707 0.4754 0.0974 0.0150 0.4697 0.4763 0.0978 0.0200 0.4688 0.4772 0.0982 0.0250 0.4678 0.4781 0.0985 0.0300 0.4669 0.4790 0.0989 0.0350 0.4660 0.4799 0.0993 0.0400 0.4650 0.4808 0.0996 0.0450
If I interpreted your request correctly, that should be the desired result.
.
  2 件のコメント
Jialin HE
Jialin HE 2022 年 2 月 19 日
That's exactly it! Thank you so much @Star Strider!
Star Strider
Star Strider 2022 年 2 月 20 日
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMultirate Signal Processing についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by