How to create a vector repeating different numbers with specific amounts?

3 vues (au cours des 30 derniers jours)
Philippe Corner
Philippe Corner le 28 Août 2018
Réponse apportée : OCDER le 28 Août 2018
If I have this matrix:
M=[1 3
2 4
3 1
4 2
5 1];
How could we obtain a vector x which repeats each entry of M(:,1) the number of M(:,2) entries obtaining:
x=[1
1
1
2
2
2
2
3
4
4
5];

Réponses (1)

OCDER
OCDER le 28 Août 2018

Catégories

En savoir plus sur Multidimensional Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by