Matlab - function that computes derivative ... pleaseee help!


ss1209
12-01-2008, 03:34 PM
You have water in a 10cm tall cylindrical can with a hole in it at the bottom. The flow from a hole depends on the water pressure, which is proportional to the height of the water above that hole: when water is W cm above a hole, then the flow from that hole will decrease the water height at a rate of 0.1*W cm/sec.

Write the function hprime = can1(t, h) that models the flow, then call ode45(@can1, [0 60], 10); to plot the water height over 60 secs starting full (10cm) . At roughly what time is there 1cm left?

I don't even know where to start ... ANY help would be sooo appreciated!! :)

davekw7x
12-01-2008, 07:02 PM
...where to start ... Look for examples of solving differential equations with matlab. The matlab function ode45 is usually considered the starting point unless you know of some special properties of your system. (This one is about as benign as you can get, so ode45 should be the ticket!)

For instance: http://coweb.cc.gatech.edu/process/202

That example shows how to use ode45 to solve the differential equation xprime = sin(t*x) for t on [0 10] with x(0) = 1

Your problem is for a range of t equal to [0 60] with x(0) = 10

What's the function you need for xprime? Well, isn't it given to be xprime = -0.1 * x, where x is the height above the hole? (The assignment calls it h in one place and W in another, but I hope you get the idea.)


Regards,

Dave