How to create a long matrix rapidly
Afficher commentaires plus anciens
I would like to create the given matrix
0 1 1 1 1 1 1 1 1 1
1 0 1 1 1 1 1 1 1 1
1 1 0 1 1 1 1 1 1 1
1 1 1 0 1 1 1 1 1 1
1 1 1 1 0 1 1 1 1 1
1 1 1 1 1 0 1 1 1 1
1 1 1 1 1 1 0 1 1 1
1 1 1 1 1 1 1 0 1 1
1 1 1 1 1 1 1 1 0 1
1 1 1 1 1 1 1 1 1 0
I thought of using the command "zeros" for the diagonal, and then use "ones", but "ones" does not exist.
For instance:
m=[0 ones(1,9);0 ones(0,9)....]
But that won't work.
How can I make such a matrix with such "condensed" commands instead of writing it out completely?
Thanks
Réponse acceptée
Plus de réponses (1)
Dyuman Joshi
le 17 Jan 2024
Modifié(e) : Dyuman Joshi
le 17 Jan 2024
1 commentaire
Sergio
le 17 Jan 2024
Catégories
En savoir plus sur MATLAB dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!