How do I write $sin(pi*x)*sin(pi*y)?
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Harshavardhan
le 9 Avr 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 commentaires
Voir également
Catégories
En savoir plus sur Boundary Conditions dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!