Functions with outputs not separated by commas
조회 수: 3 (최근 30일)
이전 댓글 표시
From documentation, I read that multiple outputs for functions should be enclosed in square brackets and separated by commas. However, there are some functions which have declared some outputs is square brackets but the outputs are not separated by commas i.e. they are just separated by an empty space. What would be the reason behind such cases?
댓글 수: 0
답변 (2개)
Stephen23
2018년 6월 23일
편집: Stephen23
2018년 6월 23일
The two are essentially equivalent. But using space characters is not recommended, because it is much easier to make mistakes and makes debugging those mistakes harder. Use commas.
Discussions on why using commas is preferred:
Information on comma-separated lists:
Summary: Using commas is preferred because it unambiguously shows the separation between each element. This applies equally to all comma-separated lists: input arguments, output arguments, concatenation, etc.
댓글 수: 0
Image Analyst
2018년 6월 23일
Which documentation item did you see that in? My guess is that they just overlooked some documentation, or examples in the documentation, when they were putting the commas in. The recommendation is to use commas after parameters.
Personally, I also like to add a space after the comma, and on either side of an equal sign, colon, or mathematical operator, but that's a matter of style.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!