声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1433|回复: 3

[编程技巧] matlab代码中特殊字符~的含义

[复制链接]
发表于 2015-10-17 10:02 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
下面程序中~符号代表什么意思?

  1. function [loss] = nneval(nn, loss, train_x, train_y, val_x, val_y)
  2. %NNEVAL evaluates performance of neural network
  3. % Returns a updated loss struct
  4. assert(nargin == 4 || nargin == 6, 'Wrong number of arguments');

  5. % training performance
  6. nn                    = nnff(nn, train_x, train_y);
  7. loss.train.e(end + 1) = nn.L;

  8. % validation performance
  9. if nargin == 6
  10.     nn                    = nnff(nn, val_x, val_y);
  11.     loss.val.e(end + 1)   = nn.L;
  12. end

  13. %calc misclassification rate if softmax
  14. if strcmp(nn.output,'softmax')
  15.     [er_train, ~]               = nntest(nn, train_x, train_y);
  16.     loss.train.e_frac(end+1)    = er_train;

  17.     if nargin == 6
  18.         [er_val, ~]             = nntest(nn, val_x, val_y);
  19.         loss.val.e_frac(end+1)  = er_val;
  20.     end
  21. end

  22. end
复制代码
回复
分享到:

使用道具 举报

发表于 2015-10-19 09:45 | 显示全部楼层
这里这个~表示未使用的输入参数,它也可以用来表示一个被忽略的输出参数。

punct      - Ignore function argument or output ~
  ~   The tilde character can be used in function definitions to
      represent an input argument that is unused within the function.
      It can also be used to indicate that an output argument of a
      function call is to ignored.  In this case, it must appear
      within [ ] and separated by commas from any other arguments.

评分

1

查看全部评分

 楼主| 发表于 2015-10-20 10:01 | 显示全部楼层
happy 发表于 2015-10-19 09:45
这里这个~表示未使用的输入参数,它也可以用来表示一个被忽略的输出参数。

原来如此,一直以为这个符号只有逻辑非的意思,谢谢
发表于 2015-11-9 13:37 | 显示全部楼层
Generation 发表于 2015-10-20 10:01
原来如此,一直以为这个符号只有逻辑非的意思,谢谢

較新版本的功能
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-9-20 17:00 , Processed in 0.063249 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表