Filter löschen
Filter löschen

Matrix Manipulation based on index

1 Ansicht (letzte 30 Tage)
Mark Cejas
Mark Cejas am 23 Aug. 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

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 23 Aug. 2013
Bearbeitet: Azzi Abdelmalek am 23 Aug. 2013

Weitere Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by