📄 horzcat.m
字号:
function P = horzcat(varargin)
% HORZCAT -- horizontal concatenation of matrix polynomials
%
% P = horzcat(P1,P2,P3,...)
% P = [P1,P2,P3,...]
%
% This function is not meant to be called directly by the user. It is
% invoked by Matlab if an expression of the form [P1,P2,...] is
% encountered.
%
% The routine lines up the exponents correctly, and concatenates
% the coefficient matrices for each power.
%
% Example:
% 3 2
% If P1 = 2 z - z and P2 = z + 3 z , then
%
% 2 3
% [P1,P2] = [2,1] z + [0,3] z + [-1,0] z
% Copyright (c) 2004 by Fritz Keinert (keinert@iastate.edu),
% Dept. of Mathematics, Iowa State University, Ames, IA 50011.
% This software may be freely used and distributed for non-commercial
% purposes, provided this copyright statement is preserved, and
% appropriate credit for its use is given.
%
% Last update: Feb 20, 2004
% convert arguments to matrix polynomials
% (some of them could be regular matrices)
for i = 1:nargin
if ~isa(varargin{i},'mpoly')
varargin{i} = mpoly(varargin{i});
end
end
if (nargin == 1)
P = varargin{1};
return
end
% check that all first dimensions agree,
% and determine highest and lowest exponents
n1 = size(varargin{1}.coef,1);
Pmin = varargin{1}.min;
Pmax = get(varargin{1},'max');
for i = 2:nargin
if (size(varargin{i}.coef,1) ~= n1)
error('sizes are not compatible');
end
Pmin = min(Pmin,varargin{i}.min);
Pmax = max(Pmax,get(varargin{i},'max'));
end
% trim all matrix polynomials to the same limits; concatenate
for i = 1:nargin
varargin{i} = trim(varargin{i},[Pmin,Pmax]);
end
P = varargin{1};
for i = 2:nargin
P.coef = cat(2,P.coef,varargin{i}.coef);
end
P = trim(P);
[type,m,r] = match_type(varargin{:});
P = set(P,'type',type,'m',m,'r',r);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -