MATLAB: MATLAB: pdepe boundary function

pdepe boundaryfunction

Why did I get an error like ''Subscript indices must either be real positive integers or logicals. Error in bcfcn (line 7) qr = Ds*J(t,1)'' when I used pdepe matlab solver to solve diffusion equation in spherical coordinate. The Ds is just an constant, but J is actually a vector with respect to time which has both very large positive and negative integers. I cannot change these value to all positive since it is a boundary condition given.
Is that because I need to change the J vector to some function with respect to time?? Actually I have tried to change all J to positive to figure out how does it work, but it doesn't work either.
Thank you very much!

Best Answer

If "Time" is the vector of time instants corresponding to J, you will have to interpolate J to the time "t" requested by the solver:
Jactual=interp1(Time,J,t);
See the example "ODE with Time-Dependent Terms" under
for a similar problem.
Best wishes
Torsten.
Related Question