numslabs.m

来自「JLAB is a set of Matlab functions I have」· M 代码 · 共 37 行

M
37
字号
function[n]=numslabs(A,B)% NUMSLABS  Counts the number of 'slabs' of one array relative to another.%  %   NUMSLABS(A,B) counts the number of size SIZE(B) elements of A, %   that is,  it returns LENGTH(A(:))./LENGTH(B(:)).  The size of A %   must be 'compatible' with that of B.%  %   See also ISCOMPAT.  %%   'numslabs --t' runs a test.%   __________________________________________________________________%   This is part of JLAB --- type 'help jlab' for more information%   (C) 2002--2006 J.M. Lilly --- type 'help jlab_license' for details    if strcmp(A, '--t')  numslabs_test,returnendif ~iscompat(A,B)   error('The size of A must be compatible with that of B.  See ISCOMPAT.')endn=numel(A)./numel(B);function[]=numslabs_test(A,B)x=[1 2; 3 4];y(:,:,2)=x;b(1)=numslabs(y,x);b(2)=numslabs(x,x);b(3)=numslabs(y,1);b(4)=numslabs(x,1);bans=[2 1 8 4];reporttest('NUMSLABS 2D and 3D cases',aresame(b,bans))

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?