Setting Array Value
Show older comments
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.
Accepted Answer
More Answers (1)
Paulo Silva
on 22 Jun 2011
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 Comments
Mohamed mohamed
on 22 Jun 2011
Paulo Silva
on 22 Jun 2011
Use the repmat function to replicate rows
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!