フィルターのクリア

how to display a value in first column the second column number of times?

1 回表示 (過去 30 日間)
johnson saldanha
johnson saldanha 2018 年 12 月 10 日
コメント済み: johnson saldanha 2018 年 12 月 10 日
suppose i have a column vector x=[1 2 3 4]; and y=[2 3 3.5 4]
i want the output as xy=[1 1 2 2 2 3 3 3 3 4 4 4 4];
the number 3.5 can be rounded off to a whole number. here ive taken it as 4.

採用された回答

Walter Roberson
Walter Roberson 2018 年 12 月 10 日
編集済み: Walter Roberson 2018 年 12 月 10 日
repelem(x, round(y))
  7 件のコメント
Walter Roberson
Walter Roberson 2018 年 12 月 10 日
cell2mat(arrayfun(@(v, n) v(ones(n,1)), x, round(y), 'uniform', 0)) %assumes inputs are column vectors
johnson saldanha
johnson saldanha 2018 年 12 月 10 日
i got the output. thank u

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by