我正在与MATLAB_R2016a合作,目前正在试图找到正确的矩阵分数描述的多输入多输入多出系统。假设我有一个表格的矩阵:
[s^2+3s+1, s+1, s^3+2s; s^3+3, s^2-6, s-5];是否有一种简单的方法来生成每个s度的系数子矩阵?就像这样:
[0, 0, 1; 1, 0, 0] s^3 + [0, 0, 0 ; 0, 1, 0] s^2 + [3, 1, 2; 0, 0, 1] s + [1,1,0;3,-6,-5];我想这可以用一个循环和提取每个多项式元素的程度来完成,但是我想知道人们是否找到了更容易的工作环境?
发布于 2017-10-04 07:22:09
我想你用符号工具箱来处理多项式。因此,作为@10a commented,您可以使用coeffs函数。你只需要做一些解决办法就能得到最终的结果。
对于任意多项式,可以使用下面的代码:
syms x
% find all coefficients for each polynomial. Results are of different sizes!
% because of different degrees of polinomils
coef = arrayfun( @(y) coeffs(y, 'All') , [2*x^2 + 3*x + 5, x^2+3; x^3, x + 7] ,...
'UniformOutput' , false)
% find max degree
max_size = cellfun( @(x) size(x,2), coef)
max_size = max(max_size(:))
% and finally fill with zeros all surplus places in arrays to get unified size
result = cellfun( @(x) [zeros(1, max_size - size(x,2)) x], coef, 'UniformOutput', false)https://stackoverflow.com/questions/46557112
复制相似问题