Setting Array Value
2 次查看(过去 30 天)
显示 更早的评论
Hello Guys I have really rather simple question: I want to set an array value into the follow [1, 3, 1, 7;1, 3, 1, 7;1, 3, 1, 7] and I used the following command a(1:3,1:3)=[1 3 1 7] But it is not working. Any clues ? Thank you.
0 个评论
采纳的回答
Matt Fig
2011-6-22
Another:
A = repmat([1,3,1,7],3,1) % change the 3 to 5 to get 5 rows, etc...
0 个评论
更多回答(1 个)
Paulo Silva
2011-6-22
r=[1 3 1 7]
a=[r;r;r]
or
r=[1 3 1 7]
b=ones(4,1)*r
b=b(1:3,:)
or
r=[1 3 1 7]
repmat(r,3,1)
2 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!