Solving system of differential equation using DSolve - Not getting simplified equation
이전 댓글 표시
Trying to solve the system of linear equations using DSolve. I am getting the solution as an integral. I want the integral to solved so that I can evaluate numerically. Can someone please help
답변 (1개)
Shivam Malviya
2023년 5월 18일
Hi,
I understand that you are interested in finding the solution of the linear equations system using “dsolve”. However, your solution contains an integral that does not allow you to calculate the numerical value of the function.
The reason is that the integral is nonelementary, which means it cannot be simplified further using elementary functions. To get the numerical value, you can follow these steps:
- Declare "C1" as a symbolic variable.
% Declare C1 as symbolic
syms C1
- Replace the symbolic constants with their actual values.
% Replace the symbolic constants with their respective value
expr = subs(simplifiedExpr,[a0,a1,a2,a3,a4,m,C1,Q_in,Q_out],[1,2,3,4,5,6,7,8,9]);
- Use the “matlabFunction” to convert the output expression into a function handle. This will change the indefinite integral into a definite integral with 0 as the lower bound and “t” as the upper bound.
% Convert the expr into function handle
f = matlabFunction(expr)
- Evaluate the function for any specific value of “t”.
% Get the value of f for any specific value of t
disp(f(0.1))
Please find the attached script for your reference.
Refer to the following links for a better understanding;
- https://in.mathworks.com/help/symbolic/dsolve.html
- https://in.mathworks.com/help/symbolic/subs.html
- https://in.mathworks.com/help/symbolic/sym.matlabfunction.html
Regards,
Shivam
댓글 수: 2
Jayesh Jawandhia
2023년 5월 18일
Shivam Malviya
2023년 5월 19일
Hi Jayesh,
A differential equation's general solution accommodates one or more unspecified constants that can be evaluated through initial or boundary conditions. To obtain the value of constant C1, apply the boundary conditions accordingly.
If you find this answer helpful, please mark it as accepted so others can benefit from it too.
카테고리
도움말 센터 및 File Exchange에서 Programming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!