To plot a first order differential equation in MATLAB, you can use the ode45 function.
In the code below, we will plot the first order differential equation: dy/dt = -2*y
main.m362 chars18 lines
This code will plot the solution to the first order differential equation dy/dt = -2*y. The ode45 function solves the differential equation for the time interval specified by tspan, with the initial condition y0. The resulting solution is stored in the vectors t and y, which are plotted using the plot function. The xlabel, ylabel, and title functions are used to label the plot.
gistlibby LogSnag