vnd.m
来自「JLAB is a set of Matlab functions I have」· M 代码 · 共 35 行
M
35 行
function[varargout]=vnd(varargin)% VND Number of dimensions% % N=VND(X) returns the number of dimensions of X. Unlike matlab,% which thinks that an array and a scalar both have dimension 2, VND% defines the dimension of a scalar to be zero and that of an array to% be one. Singleton dimensions are never counted. % % [N1,N2,...NM]=VND(X1,X2,...XM) returns the dimensions of multiple % input arguments. If zero or one output arguments are given, a% single row array [N1 N2 ...NM] is output. % __________________________________________________________________% This is part of JLAB --- type 'help jlab' for more information% (C) 2001, 2004 J.M. Lilly --- type 'help jlab_license' for details if strcmp(varargin{1}, '--t') vnd_test,returnendfor i=1:nargin x=varargin{i}; sx=size(x); nd(i)=length(sx)-length(find(sx==1)); varargout{i}=nd(i);endif nargout==0 || nargout==1 varargout{1}=nd;endfunction[]=vnd_testreporttest('VND', all(vnd(1,[1:10],[ [1:10]' [1:10]'])==[0 1 2]))
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?