how to create a matrix in sigle command?
Show older comments
single command to create this matrix c = [0 0 0 0 0;0 0 1 2 3;0 0 4 5 6;0 0 7 8 9]
Answers (1)
Torsten
on 11 Aug 2016
One single command:
c = [0 0 0 0 0;0 0 1 2 3;0 0 4 5 6;0 0 7 8 9];
Best wishes
Torsten.
4 Comments
Bimal Sah
on 11 Aug 2016
Guillaume
on 11 Aug 2016
Yes, you won't find any simpler or faster than just typing the numbers. Otherwise, you have to concatenate bits of matrices to obtain what you want:
c = [zeros(4, 3), [zeros(1, 3); reshape(1:9, 3, 3)']];
Not any clearer, and certainly slower!
Bimal Sah
on 11 Aug 2016
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!