# where derivFunction is a fHandle representing the derivative of the dependent variable wrt. the independent variable # [tSol, ySol] = ode45(derivFunction,interval,initialValue) # Example: r = 1; K = 1000; # the variables must be passed as independent variable first followed by the dependent variable odefun = @(t,P) r*P*(1-P/K); # solution interval values for t tSpan = [0,10]; P0 = 20; [tSol, PSol] = oder45(odefun,tSpan,P0) # plot results plot(tSol, PSol);
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter