What character to type for [M,I] = min(A,[],'all',___)

4 views (last 30 days)
I would like to use this function found in the matlab documentation, but Matlab gives an error when I try to run it.
Error: Invalid text character. Check for unsupported symbol, invisible character, or pasting of non-ASCII characters.
[M,I] = min(A,[],'all',___)
  1 Comment
Jonas on 19 Jul 2022
this looks like a misconception. The last argument '__' means, that there can be used any syntax describes in the documentation after min(A,[],'all',e.g.
but also just simply
[M,I] = min(A,[],'all')

Sign in to comment.

Accepted Answer

Stephen23 on 19 Jul 2022
Edited: Stephen23 on 19 Jul 2022
In the MATLAB documentation underscore is used to indicate "any other valid options shown above, in this location".
You do not use the underscore in your code.
So for your example, this
[M,I] = min(A,[],'all',___)
includes NANFLAG and (as far as I can tell from a quick read) no other optional argument, i,e.:
[M,I] = min(A,[],'all',nanflag)
[M,I] = min(A,[],'all')
The reason is very simple: The line that you showed gives us one piece of new information, namely that the 'all' option returns linear indices, and it shows how to obtain those indices (as the 2nd output argument):
[M,I] = min(A,[],'all',___) returns the linear index into A that corresponds to the minimum value in A when specifying 'all'.
Clearly there is no point in the documentation repeating every single previous 'all' syntax and repeating this exact same new information each time (e.g. this 'all' sytnax returns linear indices, this other 'all' syntax also returns linear indices, this other 'all' syntax also returns linear indices... etc), so instead the documentation simply tells states once that all syntaxes with 'all' return linear indices, and uses the underscore as a placeholder for any of the other valid options that can be used with 'all'. So one description covers multiple syntaxes. There are so many permutations of input arguments that it is neither feasible nor useful to explicitly list all permutations.
The underscore is normally explained in the documentation with the words "...for any of the previous syntaxes".

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by