0
$\begingroup$

Why does manipulation not give a graph?

Remove[y];
Remove[b];
n = 1;
k = 1;
j = Solve[k*y*(1 - y/n) - b == 0, {y}]
o[b_] := Evaluate[y /. j]
s = DSolve[y'[t] == k*y[t]*(1 - y[t]/n) - b, y[t], t];
f[t_, b_, c_] := Evaluate[y[t] /. s]
sol = Table[f[t, b, c], {c, -5, 5}]
d=Manipulate[Plot[sol, {t, -5, 5}], {b, 1, 5}]

Image

How do we correct this? How would I turn this into a gif?

$\endgroup$
3
$\begingroup$

How do we correct this? How would I turn this into a gif?

One question at a time please. For the first part, your code is not that easy to follow. Below I will only make it work, without rewriting completely (no time).

First, you need to set the constant of integration correctly. Also fix Manipulate to make it work right. This below does that

ClearAll[y, b, c, t, k, n];
n = 1;
k = 1;
j = Solve[k*y*(1 - y/n) - b == 0, {y}];
o[b_] := Evaluate[y /. j];
s = DSolve[y'[t] == k*y[t]*(1 - y[t]/n) - b, y[t], t];
f[t_, b_, c_] := Evaluate[y[t] /. s] /. C[1] -> c;
sol = Table[f[t, b, c], {c, -5, 5}];
Manipulate[
 Plot[sol /. {t -> t0, b -> b0}, {t0, -5, 5}],
 {b0, 1, 5},
 TrackedSymbols :> {b0}
 ]

Mathematica graphics

Are you sure you want to plot all the solutions at same time? For one c, you can do

Manipulate[
 Plot[sol[[1,1]] /. {t -> t0, b -> b0}, {t0, -5, 5}],
 {b0, 1, 5},
 TrackedSymbols :> {b0}
 ]

Mathematica graphics

You could add a control to decide which c you want to plot the solution for.

For exporting to animated gif, if you search this forum, there are plenty of solutions showing how to do this.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.