How do I write $sin(pi*x)*sin(pi*y)?
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Harshavardhan
el 9 de Abr. de 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 comentarios
Ver también
Categorías
Más información sobre Boundary Conditions en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!