Function that computes derivative - pleaseee help!
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 soo appreciated!!
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 soo appreciated!!
0
Comments
so, now that you know the relation between h' and h, you can write the function:
and then use ode45 as given
function hprime = can1(t,h)
F = -0.1;
hprime = -0.1*h;
... but then where does the F come in? I don't think this is right but would it need to be followed by something like W=F*hprime?
(Thanks soo much for the help again)
can you post the error that it gave you?
??? Error using ==> feval
Undefined function or method 'can1' for input arguments of type 'double'.
Error in ==> odearguments at 111
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ==> ode45 at 173
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...
test it out by calling it:
can1(1,9)
it should return -0.9
there's also a second part that says modify your function to model it with another hole 5 cm above the hole at the bottom ... any suggestions about how i would go about that one?
oh and i google searched "matlab help forum" i think!
so:
thanks for letting me know how you found us
F = -0.1; %flow rate from 1 cm of water
if h > 0.5
hprime = 2*F*h; %it goes out through 2 holes
else
hprime = F*h; %it goes out through one hole
end
end
or am I thinking about it wrong?
you know that the rate of flow out depends on the height of the water above the hole.
let's pretend that the water is 10 cm high (completely full). What's the rate of flow out of the hole that's 5cm high, and what's the rate of flow out of the bottom hole? Assume that they don't affect each other.
how high is the water above the top hole?
so you need to find how high the water is above the 5cm hole, determine the flow rate out of it, and add it to the rate out the bottom hole, and this will be the total h' when the water is > than 5cm deep
function hprime = can2(t,h)
F = -0.1; %flow rate from 1 cm of water
if h > 0.5
hprime = 1/2*F*h + F*h; %it goes out through 2 holes
else
hprime = F*h; %it goes out through 1 hole
end
... sorry, i understand the concept im just so bad at putting stuff into matlab terms
let's say the water is at 8cm.
then the water is 3cm above the top hole, and 8cm above the lower. this means:
hprime = 3*-0.1 + 8*-0.1 = -1.1
is this the same thing your formula gives?
function hprime = can2(t,h)
F = -0.1; %flow rate from 1 cm of water
if h > 0.5
hprime = F*(h-5) + F*h; %it goes out through 2 holes
else
hprime = F*h; %it goes out through 1 hole
end