How do I plot the solutions?
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentar
Walter Roberson
am 31 Jul. 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
Antworten (0)
Siehe auch
Kategorien
Mehr zu Equation Solving finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!