PDEPE: How to set I.C as a variable?

1 view (last 30 days)
Muhammad Taha Manzoor
Muhammad Taha Manzoor on 29 Jan 2020
Answered: Josh Meyer on 30 Jan 2020
Hi,
I am solving heat diffusion equation using PDEPE and I need to perform a paramtric study using non-dimensional forms.
For that I need to keep my initial temperature as a variable, which changes with the values of my attenuation coefficient.
All I need is:
function T0= heatic(T00)
T0 = T00; %%dimensionless initial temperature
end
T00 is already defined in the code. As normal funtions work, it should accept T00 as an input and assing its value to T0. But it doesn't do that.
Code works fine if I just use a numeric value of T00. But it makes my work clumpsy as I'll have to change it every time I want to run the code.
Is there anyway I can bring T00 value into this funtion?

Answers (1)

Josh Meyer
Josh Meyer on 30 Jan 2020
pdepe has expectations for the initial condition function. Namely, that it will use the functional signature:
function u0 = icfun(x)
In other words, pdepe expects this function to take 1 input, x. If you want to use another variable in the body of this function, then you need to do two things.
  1. Write the function with two inputs rather than one
  2. Pass the function to pdepe as an anonymous function that takes 1 input as pdepe expects
For example:
function T0 = heatic(x,T00)
T0 = T00; %%dimensionless initial temperature
end
and the call to the solver becomes
sol = pdepe(m,@heatpde,@(x) heatic(x,T00),@heatbc,x,t);
Notice that this anonymous function has 1 input, x. But whenever that anonymous function is called, it is supplied with the value of T00 from the workspace.

Categories

Find more on Interpolation in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!