Tried to change the diagonal elements of a magic square. Could not understand the error message.

1 vue (au cours des 30 derniers jours)
a= magic(6), diag(a)=[1 0 2 0 3 4]
Error message that I got was "Subscripted assignment dimension mismatch".
Do not understand why this happened, when you can easily replace a column or row of the matrix with similar syntax.

Réponse acceptée

Matt J
Matt J le 28 Déc 2017
Modifié(e) : Matt J le 28 Déc 2017
You cannot put a function call on the left hand side of an assignment statement. Do this instead,
a(1:7:end)=[1 0 2 0 3 4]

Plus de réponses (0)

Catégories

En savoir plus sur Get Started with MATLAB dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by