Octave / Matlab: Extend a vector making it repeat itself?

删除回忆录丶 提交于 2019-11-26 11:21:12
Andrew Shepherd

The function you're looking for is repmat().

v10 = repmat(v, 1, 5)

Obviously repmat is the way to go if you know in which direction you want to expand the vector.

However, if you want a general solution that always repeats the vector in the longest direction, this combination of repmat and indexing should do the trick:

 v10=v(repmat(1:length(v),1,5))
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!