📄 polydet.m
字号:
function [num,den,dead]=polydet(nummt,denmt,deadmt,use_Pade)
% function [num,den,dead]=polydet(nummt,denmt,deadmt)
% compute a determinant of n x n transferfunction matrix described by
% a cell array of nominator (nummt)and denominator (denmt) polynomial
% matrices. The nummt and denmt are defined in IMCTUNE as cell arrays
% of polynomial matrices. The deadmt is a matrix of dead times of the
% system. The function can also approximate dead times by
% Pade's method with the order given in the use_Pade variable.
if nargin <= 3, use_Pade = 0; end
if ~iscell(nummt)
errordlg('Not a cell array defined for IMCTUNE !');
return
end
[m,n]=size(nummt);
if m ~= n
errordlg('Not a square matrix!');
return
end
tempx=iscell(deadmt);
if tempx % Take care in case that A is cell array
temp=zeros(n,n);
for i=1:n
for j=1:n
temp(i,j)=mt2dt(deadmt{i,j},[]);
end
end
deadmt=temp;
end
if isempty(denmt) | any(iscellempty(denmt))
for i=1:n
for j=1:n
denmt{i,j}=1;
end
end
end
if use_Pade & ~all(deadmt(:)==0)
for i=1:n
for j=1:n
[temp,temp1]=pade(deadmt(i,j),use_Pade);
nummt{i,j}=conv(nummt{i,j},temp);
denmt{i,j}=conv(denmt{i,j},temp1);
end
end
deadmt=zeros(n,n);
end
if m > 1
num={0};
den={1};
dead=0;
depth=1;
for i=1:n
if ~all(nummt{1,i}==0)
nummt1=nummt;
nummt1(1,:)=[];
nummt1(:,i)=[];
denmt1=denmt;
denmt1(1,:)=[];
denmt1(:,i)=[];
deadmt1=deadmt;
deadmt1(1,:)=[];
deadmt1(:,i)=[];
[num1,den1,dead1]=polydet(nummt1,denmt1,deadmt1,use_Pade);
dead1=dead1+deadmt(1,i);
temp=(-1)^(1+i);
for j=1:length(dead1)
num1{j}=conv(num1{j},nummt{1,i});
den1{j}=conv(den1{j},denmt{1,i});
[num1{j},den1{j}]=z_p_cancel1(num1{j},den1{j},1);
num1{j}=num1{j}*temp;
if any((dead1(j)==dead))
temp1=min(find(dead1(j)==dead));
temp2=conv(den1{j},num{temp1});
num{temp1}=polyadd(temp2,conv(num1{j},...
den{temp1}));
den{temp1}=conv(den{temp1},den1{j});
[num{temp1},den{temp1}]=z_p_cancel1(num{temp1},den{temp1},1);
else
if (length(num)>1 | ~all(num{1}==0))
depth=depth+1;
end
num{depth}=num1{j};
den{depth}=den1{j};
dead(depth)=dead1(j);
end
end
end
end
else
num=nummt;
den=denmt;
dead=deadmt;
end
for j=1:length(dead) % get rid of the dead time with zero coef.
if all(num{j}==0)
num(j)=[];
den(j)=[];
dead(j)=[];
end
end
if tempx % if input deadtime is a cell array, so does the output
temp=cell(1,1);
for i=1:depth
if all(dead==0)
temp{i}=0;
else
temp{i}=dead(i);
end
end
dead=temp;
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -