Help with problem, ode45 stuff, I think it's almost done

Help with problem, ode45 stuff, I think it's almost done

Post by pupuzuke » Thu, 06 Mar 2008 22:42:11


So I've got 3 tanks with 1000 litres of water in each and 3000 kg of salt in the two corner ones and 2000 kg of salt in the middle one. I want to plot how the salt concentration in each tank shifts if they all pump out 50 litres/minute to the next tank, i.e. A -> B -> C -> A -> B.... etc.

Sooooo this is my code here:

function C=salt(t,c)

C(1,1)=(3000-t*50*C(1,1)+t*50*C(3,1))/1000
C(2,1)=(2000+t*50*C(1,1)-t*50*C(2,1))/1000
C(3,1)=(3000+t*50*C(2,1)-t*50*C(3,1))/1000

and then in another function (or the same one? I'm really bad with this ode45 stuff)

[t,c]=ode45(@salt,[0,15],[3000,2000,3000])

plot(t,c(1,:),t,c(2,:),t,c(3,:))


Yeah I get a bunch of errors >_>. Any help is very much appreciated!