How do I plot the solutions?
10 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
Walter Roberson
le 31 Juil 2019
See https://www.mathworks.com/matlabcentral/answers/474184-can-someone-explain-how-to-evaluate-a-function-with-multiple-initial-conditions-and-then-plot-it
Réponses (0)
Voir également
Catégories
En savoir plus sur Equation Solving dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!