Adding a row of ones

8 次查看(过去 30 天)
Renea Young
Renea Young 2021-11-20
评论: Renea Young 2021-11-21
I want to add a row of ones to the first row of a=[1 2 3 4;5 6 7 8;9 10 11 12; 13 14 15 16]. This 4x4 will become 5x4. Any suggestions?

采纳的回答

Atsushi Ueno
Atsushi Ueno 2021-11-20
a = [1 2 3 4;5 6 7 8;9 10 11 12; 13 14 15 16];
b = [ones(1,size(a,2)); a]
b = 5×4
1 1 1 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Multidimensional Arrays 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by