solving system of non linear equations using fsolve by converting symbolic expressions
2 ビュー (過去 30 日間)
古いコメントを表示
Ari Dillep Sai
2021 年 11 月 5 日
コメント済み: Walter Roberson
2021 年 11 月 6 日
Hi. I want to solve a system of non linear equations in 3 variables using fsolve. But the equations which i get would be in the symbolic form. My code somewhat looks like this:
%file to create equations
syms c d e x;
R=(1+(1-c-d-e+c*x^2+d*x^3+e*x^4))*(2*c+6*d*x+12*e*x^2) + (2*c*x+3*d*x^2+4*e*x^3)^2 -(1-c-d-e+c*x^2+d*x^3+e*x^4);
eq_1=int(R*x^3,x,0,1);
eq_2=int(R*x^2,x,0,1);
eq_3=int(R*x,x,0,1);
Now, I want to solve above equations using fsolve. for that i have created a separate function file, to where i copy the three equations from the command window after running this script file. what i want to know is that, is there any way to update these three equations automatically directly to the function file which i have created.
2 件のコメント
Walter Roberson
2021 年 11 月 6 日
Symbolic toolbox recognizes pure expressions with no equality in them, as implicit equality with 0. This allows you to easily do things like E = lhs(eq_1) - rhs(eq_1); fplot(E); solve(E) %solutions are places where E is 0
採用された回答
Sulaymon Eshkabilov
2021 年 11 月 5 日
Here is the solution:
syms c d e x;
R=(1+(1-c-d-e+c*x^2+d*x^3+e*x^4))*(2*c+6*d*x+12*e*x^2) + (2*c*x+3*d*x^2+4*e*x^3)^2 -(1-c-d-e+c*x^2+d*x^3+e*x^4);
eq(1)=int(R*x^3,x,0,1);
eq(2)=int(R*x^3,x,0,1);
eq(3)=int(R*x^2,x,0,1);
SOL = solve(eq==0);
c = double(SOL.c)
d = double(SOL.d)
e = double(SOL.e)
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Symbolic Math Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!