how to display a value in first column the second column number of times?
1 次查看(过去 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.
0 个评论
采纳的回答
Walter Roberson
2018-12-10
编辑:Walter Roberson
2018-12-10
repelem(x, round(y))
7 个评论
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 Center 和 File Exchange 中查找有关 Propagation and Channel Models 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!