Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Trouble with Method of Lines Matlab

  1. Mar 1, 2013 #1
    Hello, guys

    I am struggling with solving the following ODE related to radial diffusion equation:


    For easiness I have attached the main m.file with general commands in Radial_diffusion.m
    pde1d.m contains function to be solved by ODE, and dss004.m contains routines for differential solving.

    I am getting the following commands:

    Undefined function or variable 'r0'.

    Error in pde1rd (line 10)

    Error in odearguments (line 88)
    f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.

    Error in ode15s (line 149)
    [neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...

    Error in Radial_diffusion (line 30)

    Can you please indicate where I did wrong?

    Attached Files:

  2. jcsd
  3. Mar 1, 2013 #2
    Hello there,

    Your function [itex]pde1rd(t,u)[/itex] calls [itex]dss04(0.0,r0,nr,u)[/itex]. While [itex]u[/itex] is an argument of the first function and [itex]nr[/itex] is defined as a global variable, [itex]r0[/itex] is neither and is not defined within [itex]pde1rd[/itex].

  4. Mar 2, 2013 #3
    Thanks. I've got it.

    But the values of u(r,t) from the following command

    fprintf('\n nr=%2d r0=%4.2f \n', nr,r0);
    for it=1:nout
    fprintf('\n t=%4.2f\n', t(it));
    for i=1:2:nr
    fprintf('r=%4.1f u(r,t)=%8.5f\n', r(i), u(it));

    fprintf('\n ncall=%5d\n', ncall)
    show that for each value of r and t u(r,t) is zero. Why is it showing such results?
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook