Quick question!
I'm supposed to plot solution curves for the ODE y'(t)+nty(t) = 0, y(0) = 3 with integer n varying from 1 to 6 inclusive. In the process, I have to use interpolated functions obtained via NDSolve, even though the ODE in question does have analytical solutions. The final plot should look like this:
I got the graph above using Matlab, which I'm familiar with, but I'm a newbie in the Wolfram language. I began by stating the ODE:
diffEq = y'[t] + n*t*y[t] == 0
Then, I could use DSolve and obtain the analytical solution of the ODE in symbolic form with n as a parameter and proceed to plot the 6 curves, but, as mentioned above, I have to use NDSolve instead. Typing
NDSolve[{diffEq, y[0] == 3}, y[t], {t, 4}]
is no use because NDSolve needs numerical data, and the program cannot generate any without knowing the value of n. I could use a For or Table, but I still don't know how to use these commands appropriately. Some help would be great.
ParametricNDSolve
$\endgroup$