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!

댓글 수: 1

Lu Xia
Lu Xia 2016년 6월 30일
Subscript indices must either be real positive integers or logicals.
Error in bcfcn (line 7) qr = J(t,1)
Error in pdepe/pdeodes (line 337) [pL,qL,pR,qR] = feval(bc,xmesh(1),u(:,1),xmesh(nx),u(:,nx),tnow,varargin{:});
Error in ode15s (line 383) f1 = feval(odeFcn,t+tdel,y,odeArgs{:});
Error in pdepe (line 289) [t,y] = ode15s(@pdeodes,t,y0(:),opts);
Error in CsPDEbysolvers (line 18) sol=pdepe(m,@pdefun,@pdex1ic,@bcfcn,x,t);

댓글을 달려면 로그인하십시오.

 채택된 답변

Torsten
Torsten 2016년 7월 1일

0 개 추천

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.

댓글 수: 3

Lu Xia
Lu Xia 2016년 7월 1일
Thank you very much! I changed the 'qr = interp1(1:60, J(:,1)', t, 'linear', 'extrap');', it really works. But I am a little bit confused that I already set the timespan as t=1:60 which are supposed to be 60 integers. Why will the time "t" requested by the solver become totally different from the timespan I set in the main function, which has time interval smaller than 1?
Torsten
Torsten 2016년 7월 1일
The timespan you set before calling pdepe are the times where you request outputs of the solution.
The time steps the solver uses internally and the times when the solver asks you to supply pde-function + boundary conditions are set to ensure your prescribed error tolerance. They have absolutely nothing to do with your tspan-vector (except for start- and endpoint of the integration).
Best wishes
Torsten.
Lu Xia
Lu Xia 2016년 7월 1일
It is very clear. Thank you very much, Torsten!
Lu

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

질문:

2016년 6월 30일

댓글:

2016년 7월 1일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by