Is it possible to disable or get warnings when using .* on mismatched vectors?

2 vues (au cours des 30 derniers jours)
Chuck37
Chuck37 le 13 Déc 2017
Commenté : Walter Roberson le 13 Déc 2017
I've finally moved up from 2014b and I see there is a new feature(s) that lets you do math operations that would have previously resulted in errors. For example, you can now use .* on vectors of different shapes. I can see how this could be handy sometimes, but in practice, I lose track of whether a vector is a row or column and instead of getting an error, MATLAB makes a big matrix and moves on. In bad cases, the math to follow is also valid resulting in weird answers. Is there a way to at least have this give out a warning?

Réponse acceptée

Jan
Jan le 13 Déc 2017
Modifié(e) : Jan le 13 Déc 2017
No. Modern Matlab versions use "auto-expanding" e.g. for the elementwise multiplication .* . There is no way to produce a warning for this new standard behavior.
This has been discussed repeatedly and emotionally, because it has some advantages, but is an evil break with backward compatibility.
  1 commentaire
Walter Roberson
Walter Roberson le 13 Déc 2017
I know that I for one would like to be able to disable it during my test / debugging cycles.
For example it is not uncommon for me to grab existing software to try to assist someone with it -- software I did not write. That software sometimes has bugs in row vs column use. If I just go ahead and run it, then implicit expansion can end up silently giving me strange results, which I might not be able to easily distinguish from the other bugs in the code.

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