Borrar filtros
Borrar filtros

Matrix Manipulation based on index

1 visualización (últimos 30 días)
Mark Cejas
Mark Cejas el 23 de Ag. de 2013
Hi all,
I would appreciate assistance to do the following:
I have the following vector
v=[1
1
2
3
3
3
3
3
3
4
4
4
4
]'
each number of this vector is an index value that repeats a certain number of times, or not at all. I would like to use as a recipe to modify the following matrix M. The matrix M contains unique rows that pertain to a particular index value in the vector v as such:
M=
1 0.0127 5.0127
2 0.00266 5.00266
3 0.00263 5.00263
4 0.00266 5.00266
I would like to use the sequence of unique indices in v as a recipe to repeat the rows in the matrix M and produce the following matrix P:
P=
1 0.0127 5.0127
1 0.0127 5.0127
2 0.00266 5.00266
3 0.00263 5.00263
3 0.00263 5.00263
3 0.00263 5.00263
3 0.00263 5.00263
3 0.00263 5.00263
3 0.00263 5.00263
4 0.00272 5.00272
4 0.0129 5.0129
4 0.0129 5.0129
4 0.0129 5.0129
Notice the rows of matrix P are repeated in the exact sequence as listed in the index vector v.
I would greatly appreciate any help.
thank you,
Mark

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 23 de Ag. de 2013
Editada: Azzi Abdelmalek el 23 de Ag. de 2013

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing 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!

Translated by