How do I write $sin(pi*x)*sin(pi*y)?
5 views (last 30 days)
Show older comments
I tried to solve
on
and
on the boundary.
I get error when I write
. Can anyone help in the following code?
model = createpde;
g = geometryFromEdges(model,@squareg);
pdegplot(model)
pdegplot(model,'EdgeLabels','on');
axis equal
applyBoundaryCondition(model,'dirichlet','Edge',1:model.Geometry.NumEdges,'u',0);
specifyCoefficients(model,'m',0,'d',0,'c',1,'a',0,'f',sin(pi*x)*sin(pi*x));
0 Comments
Answers (1)
Harshavardhan
on 9 Apr 2025
Hi @kaps
The error you're facing is likely related to how the source term “f” is defined in the “specifyCoefficients” function. In MATLAB's PDE Toolbox, “f” should be specified as a function handle that accepts the location and state structures, even if you only need the “x” and “y” coordinates.
Here's a modification to your code to resolve the issue:
% Define the coefficients for the PDE
specifyCoefficients(model,'m',0,'d',0,'c',1,'a',0,'f', @(location, state) sin(pi*location.x).* sin(pi*location.y));
For more details on “specifyCoefficients”, you can enter the following command in the MATLAB command window:
doc specifyCoefficients
Hope this helps.
0 Comments
See Also
Categories
Find more on Boundary Conditions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!