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?

回答(2 个)

Stephen23
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.

Image Analyst
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.

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by