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

1 回表示 (過去 30 日間)
Philippe Corner
Philippe Corner 2018 年 8 月 28 日
回答済み: OCDER 2018 年 8 月 28 日
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];

回答 (1 件)

OCDER
OCDER 2018 年 8 月 28 日

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by