Logical Indexing a spefic column in a matrix
Mostrar comentarios más antiguos
Hi,
I have a matrix with 5 columns and a variable number of rows (usually around 100). Column 4 of the matrix is a set of angles that can range anywhere from -180 to 180. I want to be able to create a set of smaller matrixes that splits up the larger matrix based on whether the angles fall in a 30 degree segment or not. For example a matrix that has 0 to 30 degrees, 30 to 60 degrees, 60 to 90 degrees, etc.
Can I use something like below. I don't think that will work though.
Zero_to_Thirty = A(4,:) < 30
Any help is appreciated!
Thanks,
Pat
Respuesta aceptada
Más respuestas (1)
Roger Stafford
el 17 de Dic. de 2014
If M is the original matrix,
c4 = M(:,4);
M1 = M(0<=c4 & c4<30,:); % <-- Having the angles between 0 and 30
M2 = M(30<=c4 & c4<60,:); % <-- Having the angles between 30 and 60
etc.
2 comentarios
Stephen23
el 18 de Dic. de 2014
Surely it would be best not to split the array up into numbered variables. Doing this seems to invite the next question "how do I evaluate sequentially-numbered variable names?" which inevitably leads on to eval...
Roger Stafford
el 18 de Dic. de 2014
Not necessarily. It depends on how many there are and how they are to be used.
Categorías
Más información sobre Data Distribution Plots en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!