To model the growth of $1000 with a 3% annual interest rate in MATLAB, we can use the ode45
solver. We can define a function that calculates the change in balance over time, given a fixed interest rate. Here's an example code:
main.m306 chars17 lines
This will plot the balance growth over a 10 year time span. To solve the same problem using dsolve
, we can represent the equation directly and solve it symbolically. Here's an example code:
main.m260 chars16 lines
This will also plot the balance growth over a 10 year time span, but using a symbolic solver.
gistlibby LogSnag