📄 getmat.m
字号:
function M = getmat(L, ind)
% M = getmat(L, ind)
%
% getmat take matrix M from matrix container L
%
% in: L matrix container
% ind index (vector) of the wanted matrix (default 1)
%
% out: M matrix taken from the matrix container
%
% note: Use putmat to put the matrices into container!
% See putmat for container structure!
% (c) Heimo Ihalainen 5.8.1989 (8.8.1989 HI) (27.5.90 HI 0)
if nargin<2; ind = 1; end
ll = max(size(L)); dim = max(size(ind));
Dim = L(1); if dim~=Dim; error('Wrong index dimension!'); end
Num = L(2); if Num==0; M = []; return; end
Ind = zeros(Dim,Num); Ind(:) = L(3:Dim*Num+2);
N1 = L(Dim*Num+3:(Dim+1)*Num+2);
N2 = L((Dim+1)*Num+3:(Dim+2)*Num+2);
Mat = L((Dim+2)*Num+3:ll); lV = max(size(Mat));
mtc = zeros(Dim,Num);
for i=1:Dim; mtc(i,:) = Ind(i,:)==ind(i); end
if Dim==1; I = find(mtc==Dim); else I = find(sum(mtc)==Dim); end
if max(size(I))==0 % indices not found; get empty matrix
M = [];
else
ilf = sum(N1(1:I-1).*N2(1:I-1))+1; iri = ilf+N1(I).*N2(I)-1;
M = zeros(N1(I),N2(I)); M(:) = Mat(ilf:iri);
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -