PDE Toolbox: Parametrize geometry function
이전 댓글 표시
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!
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Geometry and Mesh에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!