MATLAB: Duplicate each element of a vector? [closed]

梦想的初衷 提交于 2019-11-28 01:44:08

use kron:

K = kron(X,Y) returns the Kronecker tensor product of X and Y. The result is a large array formed by taking all possible products between the elements of X and those of Y. If X is m-by-n and Y is p-by-q, then kron(X,Y) is m*p-by-n*q.

In your case:

kron(a,[1 1])

will give you what you wanted

Some alternatives answers for your question:

reshape([a ; a],1,[])

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