MATLAB: Time-dependent thermal conductivity

Partial Differential Equation Toolboxpdetransient thermal model

Dear Matlab community,
I am using the PDE toolbox to solve a transient thermal model. Among thermal properties, thermal conductivity changes over time. I used the function handle:
k = @(~,state) kin-(kin-kfin)/(duration/state.time);
But when I run the code, it prompts that: "Coefficient evaluation function, "@(~,state) kin-(kin-kfin)/(duration/state.time)", was requested to
calculate coefficients at 2500 locations so should have returned a matrix with 2500 columns. Instead it returned a matrix with 1
columns.
How can I solve this issue?
Thank you

Best Answer

Function should return values of k at all points requested by the solver, points are in the first argument. Update your funciton to:
k = @(location,state) ones(size(location.x))*kin-(kin-kfin)/(duration/state.time);
Related Question