how to create a matrix in sigle command?
显示 更早的评论
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]
回答(1 个)
Torsten
2016-8-11
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 个评论
Bimal Sah
2016-8-11
Guillaume
2016-8-11
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
2016-8-11
类别
在 帮助中心 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!