gcdpoly.m

来自「内模控制器(IMC)工具箱。包括参数整定、PID控制器参数转换等」· M 代码 · 共 24 行

M
24
字号
function z=gcdpoly(x,y)
% function z=gcdpoly(x,y)
% This function find the great common divisor of the two polynomial x and y
root_x=roots(x);
root_y=roots(y);
z=1;
[test,root_x,root_y]=reduce(z,root_x,root_y);
while length(test)>1
   z=conv(z,test);
   [test,root_x,root_y]=reduce(z,root_x,root_y);

end
z=z/z(end);
function [z,root_x,root_y]=reduce(z,root_x,root_y)
for i=1:length(root_x)
   for j=1:length(root_y)
      if root_x(i)==root_y(j)
         z=poly(root_x(i));
         root_x(i)=[];
         root_y(j)=[];
         return
      end
   end
end
z=1;

⌨️ 快捷键说明

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