What is the difference between commas and spaces for two variables in brackets on the command line?
조회 수: 4 (최근 30일)
이전 댓글 표시
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1224972/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1224977/image.png)
What is the difference between commas and spaces for two variables in brackets on the command line?
댓글 수: 1
Stephen23
2022년 12월 9일
"What is the difference between commas and spaces for two variables in brackets on the command line?"
The difference is clarity: space can easily be a mistake, commas make the intent clearer.
This is not just hypothetical, we regularly get questions on this thread caused by the OP adding extra spaces into their matrix construction. Using commas makes the intent clearer and the bug locations easier to identify.
답변 (2개)
Matthew
2022년 12월 9일
Previous answer is obviously correct, but if you wanted to see documentation:
In particular:
"...blank spaces act as delimiters in horizontal concatenation. When defining row vectors, you can use spaces and commas interchangeably to separate element"
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!