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

조회 수: 5 (최근 30일)
Tom K
Tom K 2022년 7월 19일
편집: Stephen23 2022년 7월 19일
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
Jonas
Jonas 2022년 7월 19일
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')

댓글을 달려면 로그인하십시오.

채택된 답변

Stephen23
Stephen23 2022년 7월 19일
편집: Stephen23 2022년 7월 19일
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".

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Assumptions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by