- Write the function with two inputs rather than one
- Pass the function to pdepe as an anonymous function that takes 1 input as pdepe expects
PDEPE: How to set I.C as a variable?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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?
0 comentarios
Respuestas (1)
Josh Meyer
el 30 de En. de 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.
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.
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!