Azzera filtri
Azzera filtri

Matrix Manipulation based on index

1 visualizzazione (ultimi 30 giorni)
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

Risposta accettata

Azzi Abdelmalek
Azzi Abdelmalek il 23 Ago 2013
Modificato: Azzi Abdelmalek il 23 Ago 2013

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by