Labfans是一个针对大学生、工程师和科研工作者的技术社区。 论坛首页 | 联系我们(Contact Us)
MATLAB爱好者论坛-LabFans.com
返回   MATLAB爱好者论坛-LabFans.com > 其它 > 资料存档
资料存档 资料存档
回复
 
主题工具 显示模式
旧 2019-12-10, 20:30   #1
poster
高级会员
 
注册日期: 2019-11-21
帖子: 3,006
声望力: 66
poster 正向着好的方向发展
帖子 Matlab未使用的输入符号详细信息

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

更多&回答...
poster 当前离线   回复时引用此帖
回复


发帖规则
不可以发表新主题
不可以发表回复
不可以上传附件
不可以编辑自己的帖子

启用 BB 代码
论坛禁用 表情符号
论坛启用 [IMG] 代码
论坛启用 HTML 代码



所有时间均为北京时间。现在的时间是 05:14


Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.