Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想知道在 Matlab 中实现什么的最快方法是在 RI 中使用rep()带参数的函数实现什么times,例如
rep()
times
v1=1:5;v2=5:1;out=rep(v1,times=v2);out # 1 1 1 1 1 2 2 2 2 3 3 3 4 4 5
即复制 vector 中的每个元素v1的次数由 vector 中的相应元素给出v2。有什么想法吗?
v1
v2
您可以使用repmator repelems,例如
repmat
repelems
z = repelems(x,[1:4;rep])