matlab怎么算多元多项式,matlab - 操纵多元多项式的最佳方法Matlab - 堆栈内存溢出...

终于我找到了一种解决方案。 不幸的是(或没有),我使用了Symbolic Toolbox 。 就我而言,我考虑了7个符号变量,多项式的变量是X和Y matlab变量poly是一个包含字段p的struct 。 p是多项式的symfun矩阵。

对于输出参数, C , E , MX和MY分别包含在polyOut.mult , polyOut.exph , polyOut.expoX和polyOut.expoY 。

%% Build the polynomial matrices

function polyOut=buildPolyMat(poly)

syms X Y real

syms c11 c12 c21 c22 c33 real

P=poly.p(X,Y);

sizP=size(P);

polyOut.mult=sym(zeros(sizP));

polyOut.expoX=zeros(sizP);

polyOut.expoY=zeros(sizP);

%for each term of the polynomial matrix

for it=1:prod(sizP)

%polynomial

pT=P(it);

%read coeff and exponents

[C,M]=coeffs(pT,[X,Y]);

if ~isempty(C)

%subscripts in matrix

[sC,sR]=ind2sub(sizP,it);

%exponents

for iE=1:numel(C)

eX=feval(symengine,'degree',M(iE),X);

eY=feval(symengine,'degree',M(iE),Y);

polyOut.mult(sC,sR,iE)=C(iE);

polyOut.expoX(sC,sR,iE)=eX;

polyOut.expoY(sC,sR,iE)=eY;

end

end

end

polyOut.exph=poly.eH*ones(size(polyOut.mult));

%clean matrices with zeros multiplier

Ind=(polyOut.mult==0);

polyOut.expoX(Ind)=0;

polyOut.expoY(Ind)=0;

polyOut.exph(Ind)=0;

end

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值