Can someone explain how to evaluate a function with multiple initial conditions? And then plot it?
6 ビュー (過去 30 日間)
古いコメントを表示
This is what I have so far. I don't need the exact answer, but any help would be greatly appreciated!!! I need to plot the 3 different symbolic solutions to the IVP on the figure.
%Define the variables using syms
syms y(t) y0 y t
%define the ordinary differential equation
ode = diff(y,t) == cos(t^2);
%solve the differential equation using dsolve
ysol = dsolve(ode)
%Create a figure called Task 1
figure ('Name','Task 1')
%Pick 3 different initial conditions for which the solution exists
conds = [1 1.5 3];
0 件のコメント
回答 (1 件)
Walter Roberson
2019 年 7 月 30 日
編集済み: Walter Roberson
2019 年 7 月 30 日
ysol = dsolve(ode, y(0)==y0)
After which subs(ysol, y0, conds) to get the three different equations.
2 件のコメント
Walter Roberson
2019 年 7 月 31 日
%Define the variables using syms
syms y(t) y0
%define the ordinary differential equation
ode = diff(y,t) == cos(t^2);
%solve the differential equation using dsolve
ysol = dsolve(ode, y(0)==y0);
%Create a figure called Task 1
figure ('Name','Task 1')
%Pick 3 different initial conditions for which the solution exists
conds = [1 1.5 3];
eqns = subs(ysol, y0, conds);
t_end = 10;
fplot(eqns, [0 t_end])
legend(string(conds))
参考
カテゴリ
Help Center および File Exchange で Equation Solving についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!