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

6 visualizaciones (últimos 30 días)
Tom K
Tom K el 19 de Jul. de 2022
Editada: Stephen23 el 19 de Jul. de 2022
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 comentario
Jonas
Jonas el 19 de Jul. de 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.
min(A,[],'all','includenan')
but also just simply
[M,I] = min(A,[],'all')

Iniciar sesión para comentar.

Respuesta aceptada

Stephen23
Stephen23 el 19 de Jul. de 2022
Editada: Stephen23 el 19 de Jul. de 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".

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by