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

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

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Propagation and Channel Models 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by