How do I plot the solutions?

7 visualizaciones (últimos 30 días)
Vincenzo  Dragone
Vincenzo Dragone el 30 de Jul. de 2019
Comentada: Walter Roberson el 31 de Jul. de 2019
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 comentario
Walter Roberson
Walter Roberson el 31 de Jul. de 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

Iniciar sesión para comentar.

Respuestas (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by