What is the answer of [(4 -2 ) /2 , 5 +6 , 7 , 8 ] ? Why does MATLAB output [1 5 6 7 8]?
53 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
When the plus sign is preceded by a blank space:
[(4 -2 ) /2 , 5 +6 , 7 , 8 ]
Delete blank space:
[(4 -2 ) /2 , 5+6 , 7 , 8 ]
I don't understand why MATLAB will output different results.
Under normal circumstances, shouldn't spaces be ignored?
0 commentaires
Réponse acceptée
Plus de réponses (3)
Steven Lord
le 24 Fév 2023
1 commentaire
Stephen23
le 24 Fév 2023
Modifié(e) : Stephen23
le 24 Fév 2023
There is nothing on that page that explicitly explains how space is interpreted around arithmetic operators when building arrays:
[1 - 2]
[1 -2]
This topic comes up fairly regularly on Answers, indicative of confusion regarding this topic, and that page looks like a good place to document it. None of the other "obvious" pages I found in a quick search now covered this topic either, e.g.:
Voir également
Catégories
En savoir plus sur Entering Commands 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!