Adding a row of ones

4 vues (au cours des 30 derniers jours)
Renea Young
Renea Young le 20 Nov 2021
Commenté : Renea Young le 21 Nov 2021
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?

Réponse acceptée

Atsushi Ueno
Atsushi Ueno le 20 Nov 2021
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
  1 commentaire
Renea Young
Renea Young le 21 Nov 2021
Thank you

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by