Solving exact ODE and fplotting a solution curve.
古いコメントを表示
I use MATLAB 2023a with the symbolic math toolbox.
I am trying to solve the following exact ODE with an initial condition and plot a solution curve.
Since I do not know how to implement dx or dy in MATLAB code, I changed the above equation as follows:
Then, I wrote the following code:
syms y(x);
ode = (exp(x + y) + y*exp(y)) + (x*exp(y) - 1)*diff(y, x, 1) == 0
cond = y(0) == -1;
sol = dsolve(ode, cond, 'Implicit', true)
%% In the sol, sol(1) is a trivial solution.
%% Plotting a solution curve.
fplot(sol)
%% Plotting a solution curve with the non-trivial solution.
fplot(sol(2))
%% The above command also produces the following ERROR messsage.
% Error using fplot
% Input must be a function handle or symbolic function.
My question is as follows:
First, why does dsolve() produce a trivial solution, i.e., sol(1)? Also if a way of excluding any trivial solution exists, please let me know.
Second, is there a way to implement dx and dy in MATLAB as originally shown in equation (eq 1)? If not, is there a way of implementing the original ODE problem in an easy way?
Third, how to plot a solution curve of the (non-trivial) particular solution, i.e. sol(2)?
Thank you for your time.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Numeric Solvers についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!





