How do I extract only the rows from a matrix that meet a specific requirement?
    2 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Jialin HE
 el 19 de Feb. de 2022
  
    
    
    
    
    Comentada: Star Strider
      
      
 el 20 de Feb. de 2022
            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 comentarios
Respuesta aceptada
  Star Strider
      
      
 el 19 de Feb. de 2022
        ‘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 comentarios
  Star Strider
      
      
 el 20 de Feb. de 2022
				My pleasure!  
                                        If my Answer helped you solve your problem, please Accept it!
.
Más respuestas (0)
Ver también
Categorías
				Más información sobre Language Fundamentals en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

