PDE Toolbox - function handle specification
Ältere Kommentare anzeigen
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?
14 Kommentare
Walter Roberson
am 23 Feb. 2026 um 18:08
I think it would help if we had your code.
Steven Lord
am 23 Feb. 2026 um 18:51
The full and exact text of the error message could be useful in diagnosing the root cause of the error as well.
Thomas
am 23 Feb. 2026 um 20:16
Walter Roberson
am 23 Feb. 2026 um 20:25
Walter Roberson
am 23 Feb. 2026 um 20:58
Surely your function handles could be written to test the size of the array?
Thomas
am 24 Feb. 2026 um 12:48
The coefficient functions are designed to compute their return values based on the values of x,y and u in one point for which they are called. Why is it necessary in your case to reference more than one point per call ? What do you want to specify by the coefficient function ?
Thomas
am 24 Feb. 2026 um 13:39
So in your PDE model, the number of partial differential equations is also 3 (as assumed in the fcoeffunction implementation from https://www.mathworks.com/help/pde/ug/f-coefficient-for-specifycoefficients.html ) and you get an error when you try to reference state.u(2,:), state.u(3,:), state.ux(2,:), state.ux(3,:), state.uy(2,:) or state.uy(3,:) ?
Thomas
am 24 Feb. 2026 um 19:41
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
am 25 Feb. 2026 um 14:40
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).
Well, don't feel insulted, but I think it's self-evident that you need to first specify how many equations you want to solve if you want to use a function that needs this information to properly dimension its array sizes. But after all, it's good to hear that you could resolve your problem.
Antworten (0)
Kategorien
Mehr zu Eigenvalue Problems finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!