括号中的波浪号 [英] Tilde character in the brackets

查看:46
本文介绍了括号中的波浪号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 MATLAB 中,以下代码的作用是什么:

In MATLAB, what does the following code do:

[m, ~]=func_returning_matrix()

波浪号运算符 ~ 有什么作用?

What does the tilde operator, ~, do?

推荐答案

在 Matlab 中,这意味着不要从赋值的 rhs 上的函数中分配相应的输出参数.因此,如果 func_returning_matrix 返回 2 个参数,则表达式会将第一个参数分配给变量 m 而忘记第二个.如果 func_returning_matrix 返回 3 个(或更多)参数,则表达式将从函数中删除第二个和所有后续输出.

In Matlab it means don't assign the corresponding output argument(s) from the function on the rhs of the assignment. So, if func_returning_matrix returns 2 arguments, the expression will assign the first to the variable m and forget the second. If func_returning_matrix returns 3 (or more) arguments, then the expression will drop the second and all later outputs from the function.

这篇关于括号中的波浪号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆