Info
この質問は閉じられています。 編集または回答するには再度開いてください。
solve 4 equations with 4 unknows
1 回表示 (過去 30 日間)
古いコメントを表示
function polynomial()
%Write the equations
syms a
syms b
syms c
syms d
equation1=(a*xk6+b*xk5+c*xk4+d*xk3-xk3yk);
equation2=(a*xk5+b*xk4+c*xk3+d*xk2-xk2yk);
equation3=(a*xk4+b*xk3+c*xk2+d*xk-xkyk);
equation4=(a*xk3+b*xk2+c*xk+d*n-yk);
sol.a=solve(equation1,equation2,equation3,equation4); UNKNOWNS a,b,c,d . others knowns.
P3=a*x^3+b*x^2+c*x+d;
disp('P3(x)=');
disp(P3);
end
That solution gives me ;
P3(x)=
a*x^3 + b*x^2 + c*x + d
ans =
a: [1x1 sym]
b: [1x1 sym]
c: [1x1 sym]
d: [1x1 sym]
BUT I WANT REAL NUMBERS NOT MATRIX. PLEASE HELP IMMEDIATELY.
2 件のコメント
Walter Roberson
2019 年 4 月 18 日
You have several undefined variables there, such as xk6.
You sent me email with a variation of this code in which some of those variables were calculated based upon input(), but you did not include sample inputs to test with.
You are passing multiple equations into solve(). You will either get back the empty array or a structure of values. You assign the structure to sol.a but you never use the structure afterwards: you proceed to use a, b, c, d that are still the "syms" that you calculated before. You should
subs(P3, sol.a)
回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!