Matlab Unused Input Notation Data

Matlab R2009b introduced a new “operator” - ~ - to symbolize an unused output or function input. I have a detailed question about this implementation. (Calling all @Loren .)

What does the function see for the value of an unused input parameter?

i.e. if my function is defined as

myfunc(argOne, argTwo, argThree)

and is called like this:

myfunc('arg', ~, 'arg')

Nargin 2 or 3? Is argTwo undefined or empty or something else?

thank

+3
source share
1 answer

~ , ( ). , :

function myfunc(argOne, ~, argThree)  %# Will do nothing with the second input
  %# Do stuff here
end

:

myfunc('arg', ~, 'arg');  %# Error city ;)

, ~ :

[~, I] = sort([2 4 1 2 5 3]);  %# Sort the vector and keep only the index
+4

Source: https://habr.com/ru/post/1727291/


All Articles