MATLAB: PDE Toolbox: Parametrize geometry function

2d geometryanonymous functionfunction handlefunction parametrizationpde toolbox

I aim to generate geometries in a programmatic way to explore the influence of geometry shape on a PDE solution. I generate the geometry with a geometry function as outlined here: Create geometry using a geometry function . In order to specify the geometry, I would like to pass certain parameters to the function before creating the geometry. I tried using a function handle but could not get it to work. Currently I use a workaround with a global variable but would very much like to avoid this.
Here a minimal example:
>> para = rand(1,20); %random numbers as parameters
>> fun = @(bs,s)GetPolygon2(bs,s,para); %creating function handle
>> class(fun)
ans =
'function_handle'
>> pdegplot(@fun,'EdgeLabels','on')
Error: "fun" was previously used as a variable, conflicting with its use here as the name of a function or command.
See "How MATLAB Recognizes Command Syntax" in the MATLAB documentation for details.
>> pdegplot('fun','EdgeLabels','on')
Undefined function or variable 'fun'.
Error in pdeigeom (line 39)
x=dl();
Error in pdegplot>plotTwoDGeometry (line 99)
nbs=pdeigeom(g);
Error in pdegplot (line 87)
hh = plotTwoDGeometry(g, plotVertexLabels, plotEdgeLabels, plotSubLabels);
The function pdegplot works fine when I remove the additional input argument "para" from the function GetPolygon2 and use the workaround of a global variable:
>> pdegplot(@GetPolygon2,'EdgeLabels','on')
In case anybody knows a way to pass additional parameters to a geometry function that would be great. Thank you!

Best Answer

Strangely enough, someone else asked a question about this subject at about the same time. There, this pointer gave an answer. You could also look here for a slightly different explanation of the same material.
Alan Weiss
MATLAB mathematical toolbox documentation