Info

この質問は閉じられています。 編集または回答するには再度開いてください。

solve 4 equations with 4 unknows

1 回表示 (過去 30 日間)
Onur Ozturk
Onur Ozturk 2019 年 4 月 18 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
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
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)
Rik
Rik 2019 年 4 月 18 日
This time I edited your question for you. Next time, please use the tools explained on this page to make your question more readable.

回答 (0 件)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by