SOLVING LARGE SYSTEM OF EQUATIONS
이전 댓글 표시
Hi, this is my code (the only think that matters is the last line)
a = sym('a',[1 15]);
sym r
p1 = poly2sym(a,r);
diff = sym('diff');
eq = sym('eq');
fprintf('\n polynomial: %s\n', p1);
p2 =poly2sym(a,r);
p2=subs(p2,r,r-1);
%fprintf('\n p2: %s\n', p2);
diff= p1-p2;
%fprintf('\n diff: %s\n', simplify(diff));
diff = coeffs(diff,r);
branch2=prod(r-3:r+5)*(((1/1920)*(r+4)*(r+3)*(r^2+r-10))+((1/5120)*r*(r+1)*(r^2+r-10))+((1/9216)*(r+4)*(r+3)*(r+3)*(r-2)*(r-4)));
%fprintf('\n branch: %s\n', simplify(branch2));
%display(diff);
branch2=coeffs(branch2,r);
for u=1:14
%fprintf('DIFF: %d = %s\n', u, diff(u));
%fprintf('BRANCH: %d = %s\n', u, branch2(u));
eq(u)= diff(u)==branch2(u);
fprintf('EQ %d : %s\n', u, eq(u));
%eqcoef(u)=coeffs(diff(u),[a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14]);
% fprintf('EQCOEF %d : %s\n', u, eqcoef(u));
end
[A,B] = equationsToMatrix([eq(1), eq(2), eq(3),eq(4), eq(5), eq(6),eq(7), eq(8), eq(9),eq(10), eq(11), eq(12),eq(13),eq(14)], [a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14]);
I would like to solve the system. But this gives me an error that a1 is not defined. But it is. Any help?
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Polynomials에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!