How do I plot the solutions?
8 ビュー (過去 30 日間)
古いコメントを表示
This is the code I have so far, but I can't figure out how to plot the 3 solutions given the 3 initial conditions. Can anyone help?????
%Define the variables using syms - syms creates symbolic variables
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
%Conditions are the y values (y values are 1, 1.5, and 3 at varying t
%values. See the t values below.
conds = [1 1.5 3];
subs(ysol,y0,conds);
plot(ode,'color',rand(1,3),'linewidth',2)
title('Symbolic Solutions')
xlabel('t')
ylabel('y')
grid on
1 件のコメント
Walter Roberson
2019 年 7 月 31 日
See https://www.mathworks.com/matlabcentral/answers/474184-can-someone-explain-how-to-evaluate-a-function-with-multiple-initial-conditions-and-then-plot-it
回答 (0 件)
参考
カテゴリ
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!