Functions with outputs not separated by commas

4 views (last 30 days)
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?

Answers (2)

Stephen23
Stephen23 on 23 Jun 2018
Edited: Stephen23 on 23 Jun 2018
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.

Image Analyst
Image Analyst on 23 Jun 2018
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.

Categories

Find more on Matrices and Arrays in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!