Generation 发表于 2015-10-17 10:02

matlab代码中特殊字符~的含义

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

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

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

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

%calc misclassification rate if softmax
if strcmp(nn.output,'softmax')
                   = nntest(nn, train_x, train_y);
    loss.train.e_frac(end+1)    = er_train;

    if nargin == 6
                   = nntest(nn, val_x, val_y);
      loss.val.e_frac(end+1)= er_val;
    end
end

end

happy 发表于 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.

Generation 发表于 2015-10-20 10:01

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

原来如此,一直以为这个符号只有逻辑非的意思,谢谢

ChaChing 发表于 2015-11-9 13:37

Generation 发表于 2015-10-20 10:01
原来如此,一直以为这个符号只有逻辑非的意思,谢谢

較新版本的功能
页: [1]
查看完整版本: matlab代码中特殊字符~的含义