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

6 ビュー (過去 30 日間)
Muhammad Taha Manzoor
Muhammad Taha Manzoor 2020 年 1 月 29 日
回答済み: Josh Meyer 2020 年 1 月 30 日
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?

回答 (1 件)

Josh Meyer
Josh Meyer 2020 年 1 月 30 日
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.

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by