- #1

k0st123

- 2

- 0

I am trying to solve the following simple diffusion equation using the method of lines:

du/dt=D(du2/dx2)function k=func1()

k = [0, 0, 0, 0, 0, 0, 0.4380, 0, 1e5]; %k(9) initial value of the molecules

end %k(7) D/dx2

function k=func2()

c = [0 0 0 0 0 0 0 0];

end

function cx = eqn(t,c,k)

fb = [ 2*k(7)*c(2)-2*k(7)*c(1)-k(7)*k(9); % du1/dt

k(7)*c(3)-2*k(7)*c(2)+k(7)*c(1); % du2/dt

k(7)*c(4)-2*k(7)*c(3)+k(7)*c(2); % du3/dt

k(7)*c(5)-2*k(7)*c(4)+k(7)*c(3); % du4/dt

k(7)*c(6)-2*k(7)*c(5)+k(7)*c(4); % du5/dt

k(7)*c(7)-2*k(7)*c(6)+k(7)*c(5); % du6/dt

k(7)*c(8)-2*k(7)*c(7)+k(7)*c(6); % du7/dt

-2*k(7)*c(8)+k(7)*c(7)]; % du8/dt

endk = func1;

c = func2;

ts1 = [1 1000];

[A,B] = ode45(@(t,y)eqn(t,y,k),ts1, c);

I am using mesh for A and B but the results I get seem unexpected.

Could anyone please point me to what the problem could be? Are my equations right??

Thanks

k0st123