maximizing efficiency in simple commands
显示 更早的评论
I have an array given by
x = [1 2 3 4];
I would like to create a matrix that looks like
M = [1 2 3 4;
1 2 3 4;
1 2 3 4;
1 2 3 4];
What's the most computationally efficient way to create M from x?
采纳的回答
更多回答(1 个)
Andrei Bobrov
2013-8-20
编辑:Andrei Bobrov
2013-8-20
ones(4,1)*x
kron(ones(4,1),x)
类别
在 帮助中心 和 File Exchange 中查找有关 Data Types 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!