📄 getm3.m
字号:
function Matrix = getm3(multiMatrix, row, col, ix1, ix2, ix3, ix4, ix5, ix6)% RECVAR, A package for new data types in Matlab 4. % (c) FOA 1997. See the file rvright.m for copyright notice.%% Gets a two dimensional matrix from a part of a multidimensional matrix % (multimatrix). The index/subscript that will form different rows in the % output matrix can be specified.% Matlab 5 compatibility version.% See "help getm3" in main RECVAR directory for more information.% Start : 970820 Svante Bj鰎klund (svabj).% Latest change: $Date: 1998/07/12 18:44:07 $ $Author: svabj $.% $Revision: 1.2 $% *****************************************************************************maxNoIndex = 6;% ****************** Add missing input parameters ******************if (nargin < 9) ix6 = 1;endif (nargin < 8) ix5 = 1;endif (nargin < 7) ix4 = 1;endif (nargin < 6) ix3 = 1;endif (nargin < 5) ix2 = 1;end%if (nargin < 4)% ix1 = 1;%end% ****************** ****************** sizeMM = size(multiMatrix);sizeMM = [sizeMM ones(1,maxNoIndex-size(sizeMM,2))];if (isstr(ix1) & (ix1 == ':')) ix1 = 1:sizeMM(1,1);endif (isstr(ix2) & (ix2 == ':')) ix2 = 1:sizeMM(1,2);endif (isstr(ix3) & (ix3 == ':')) ix3 = 1:sizeMM(1,3);endif (isstr(ix4) & (ix4 == ':')) ix4 = 1:sizeMM(1,4);endif (isstr(ix5) & (ix5 == ':')) ix5 = 1:sizeMM(1,5);endif (isstr(ix6) & (ix6 == ':')) ix6 = 1:sizeMM(1,6);endMatrix = squeeze(multiMatrix(ix1, ix2, ix3, ix4, ix5, ix6));% ********************* getm code for Matlab5 *********************if ((size(Matrix,1) == 1) & (size(Matrix,2) > 1)) % All vectors are turned to row vectors. Matrix = Matrix.';end%if% ********************* Transpose if necessary for getm3 *********************indexLengths = [length(ix1), length(ix2), length(ix3), length(ix4), ... length(ix5), length(ix6)];noOfIx = 6;%for n = 1:noOfIxn = 1;finished = 0;while ((n <= noOfIx) & ~finished) %fprintf('n=%d, %d & %d \n',n,(indexLengths(n) > 1),(n ~= row)) if (indexLengths(n) > 1) finished = 1; if (n ~= row) % If the first index that is a vector is not the same as specified with % "row" then transpose. If no index is a vector no transposition is done. % If "row" index is no vector but there are two other vectors there % should be an error message there is none. Matrix = Matrix.'; %fprintf('Transposition.\n') end%if end%if n = n +1;end%while
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -