PDE Toolbox - function handle specification

51 views (last 30 days)
Thomas
Thomas on 23 Feb 2026 at 17:39
Commented: Thomas about 1 hour ago
I am setting up a system of equations using the PDE Toolbox, but I seem to be running into some issues with this. My current formulation uses function handles for some of the coefficients in the form f(location,state); however, when I attempt to set the model coefficients to these values, an error is thrown within the coefficient validation function (specifically, the portion where a check is made that the function is of the form f(p,t,u,time)).
I am confused why this form is needed as the documentation specifies that the function handle should be of the first form (having location and state passed as input arguments). Is this additional check intended to occur in all cases, or am I potentially misunderstanding the documentation here?
  13 Comments
Torsten
Torsten about 1 hour ago
Edited: Torsten about 1 hour ago
If this were true, it would be a bug. If you can't share an example file that reproduces this behaviour here in the forum, you should report it to Mathworks support and ask for help there.
Maybe you define the number of equations used in your model after you define the coefficient functions ?
Thomas
Thomas 37 minutes ago
@Torsten @Steven Lord I was able to resolve this issue by explicitly setting the PDESystemSize property for the model prior to calling specifyCoefficients with my function handles (this property is used to appropriately size the sample state matrices for function validation). It appears that this property is not set automatically and must be set manually by the user when initializing a model; however, this is not identified in the documentation as a necessary step when using function handles like the ones I've described (and the ones that are provided in the examples from the documentation).

Sign in to comment.

Answers (0)

Products


Release

R2024a

Community Treasure Hunt

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

Start Hunting!