Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
|
![]() |
#1 |
高级会员
注册日期: 2019-11-21
帖子: 3,006
声望力: 66 ![]() |
![]()
Matlab R2009b引入了一个新的“运算符”-〜-表示未使用的函数输出或输入。我对此实施有详细的疑问。 (调用所有@Loren 。)
对于未使用的输入参数的值,函数会看到什么? 即如果我的功能被定义为 myfunc(argOne, argTwo, argThree) 它这样称呼: myfunc('arg', ~, 'arg') nargin是2还是3?是argTwo未定义还是为空或其他? 谢谢 回答: ~语法仅适用于函数定义的输入,不适用于函数调用的输入(如本文档页面上所述 )。换句话说, 这是可以的: 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 更多&回答... |
![]() |
![]() |