What is the answer of [(4 -2 ) /2 , 5 +6 , 7 , 8 ] ? Why does MATLAB output [1 5 6 7 8]?
53 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
更多回答(3 个)
Steven Lord
2023-2-24
1 个评论
Stephen23
2023-2-24
编辑:Stephen23
2023-2-24
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.:
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Entering Commands 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!