Why does my code say incorrect number or types of inputs or outputs for function specifyCoefficients?

39 次查看(过去 30 天)
specifyCoefficients(smodel,'m', 1520,'d', 0,'c', 1,'a', 0, 'f', 0, 'Face', 1:3);
This is the code I'm trying to run with Matlab's PDE toolbox, but it says "incorrect number or types of inputs or outputs for function specifyCoefficients."
How do I fix the code?

回答(1 个)

Walter Roberson
Walter Roberson 2024-3-10
There is no 'Face' parameter for that call.
  7 个评论
Torsten
Torsten 2024-3-11
编辑:Torsten 2024-3-11
Can you run the following worked-out example from the PDE toolbox ?
Maybe you created a function with name "specifyCoefficients.m" in your working directory which overrides the built-in MATLAB function ?
model = createpde();
geometryFromEdges(model,@circleg);
figure
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",1);
hmax = 0.1;
generateMesh(model,"Hmax",hmax);
figure
pdemesh(model);
axis equal
results = solvepde(model);
u = results.NodalSolution;
pdeplot(model,"XYData",u)
title("Numerical Solution");
xlabel("x")
ylabel("y")
hmax = 0.1;
error = [];
err = 1;
while err > 5e-7 % run until error <= 5e-7
generateMesh(model,"Hmax",hmax); % refine mesh
results = solvepde(model);
u = results.NodalSolution;
p = model.Mesh.Nodes;
exact = (1 - p(1,:).^2 - p(2,:).^2)/4;
err = norm(u - exact',inf); % compare with exact solution
error = [error err]; % keep history of err
hmax = hmax/2;
end
plot(error,"rx","MarkerSize",12);
ax = gca;
ax.XTick = 1:numel(error);
title("Error History");
xlabel("Iteration");
ylabel("Norm of Error");
figure
pdemesh(model);
axis equal
figure
pdeplot(model,"XYData",u)
title("Numerical Solution");
xlabel("x")
ylabel("y")
p = model.Mesh.Nodes;
exact = (1 - p(1,:).^2 - p(2,:).^2)/4;
pdeplot(model,"XYData",u - exact')
title("Error");
xlabel("x")
ylabel("y")
Walter Roberson
Walter Roberson 2024-3-11
The dbstop is not intended as a cure for the problem. The dbstop tells the system that you want to debug specifyCoefficients from the beginning, and after you give that command, calling specifyCoefficients should stop in the debugger.

请先登录,再进行评论。

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by