⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iscompat.m

📁 JLAB is a set of Matlab functions I have written or co-written over the past fifteen years for the p
💻 M
字号:
function[bool]=iscompat(a,b)%ISCOMPAT  Tests whether an array's size is "compatible" with another's.%%   ISCOMPAT(A,B) returns true if the sizes of the dimensions of A and%   B is the same, up to the dimensionality of B.  The size of A is%   then said to be "compatible" with the size of B. This permits, for%   example, B to be a matrix of spatial positions, and A to contain%   some time-varying  parameter at those positions.%%   By 'dimensionality' of B is meant ND(B), not NDIMS(B).%   _________________________________________________________________%   This is part of JLAB --- type 'help jlab' for more information %   (C) 2003, 2004 J.M. Lilly --- type 'help jlab_license' for details      if strcmp(a, '--t')  iscompat_test,returnendsizea=size(a);sizeb=size(b);ndb=nd(b);if ndb>0  bool=all(sizeb(1:ndb)==sizea(1:ndb));else  %B is scalar; special case  bool=1;endfunction[]=iscompat_testx=[1 2; 3 4];y(:,:,2)=x;b(1)=iscompat(y,x);b(2)=iscompat(y,1);b(3)=iscompat(y,1:2);b(4)=iscompat(y,[1:2]');b(5)=iscompat(x,[1:2]');  %This would fail with the usual NDIMSbool=aresame(b,[1 1 0 1 1]);reporttest('ISCOMPAT',bool)

⌨️ 快捷键说明

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