PDE Toolbox - function handle specification
Mostrar comentarios más antiguos
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 comentarios
Walter Roberson
el 23 de Feb. de 2026 a las 18:08
I think it would help if we had your code.
Steven Lord
el 23 de Feb. de 2026 a las 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
el 23 de Feb. de 2026 a las 20:16
Walter Roberson
el 23 de Feb. de 2026 a las 20:25
Walter Roberson
el 23 de Feb. de 2026 a las 20:58
Surely your function handles could be written to test the size of the array?
Thomas
el 24 de Feb. de 2026 a las 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
el 24 de Feb. de 2026 a las 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
el 24 de Feb. de 2026 a las 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
el 25 de Feb. de 2026 a las 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.
Respuestas (0)
Categorías
Más información sobre Eigenvalue Problems en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!