Matrix Manipulation based on index

1 次查看(过去 30 天)
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

采纳的回答

Azzi Abdelmalek
Azzi Abdelmalek 2013-8-23
编辑:Azzi Abdelmalek 2013-8-23

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by