PDE toolbox, specifying coefficients, error telling me "Function specifying a coefficient must accept two input arguments and return one output argument."

1 vue (au cours des 30 derniers jours)
Hi all,
I keep running into the error while I am specifying f coefficient and the problem is I do not know why.
It would be very much appreciated if somebody kindly point me into the right direction. I have given my code below.
clc; tic; % Clears the screen
clear all;
e=0.5;
mu=0.00689;
V=265.988178;
omega=1047.197;
C=0.0000508;
R=0.508/2;
phi=45;
L=0.127;
%v=12*mu/h^3;
phi=45;
model = createpde();
rect1 = [3,
4,
-1,
1,
1,
-1,
0.3,
0.3,
-0.3,
-0.3];
r=decsg(rect1);
geometryFromEdges(model,r);
applyBoundaryCondition(model,'dirichlet','Edge',1:4,'u',1*10^5);
specifyCoefficients(model,'m',0,...
'd',0,...
'c',1,...
'a',0,...
'f',@fcoeffunction);
generateMesh(model,'Hmax',0.083);
results = solvepde(model);
p= results.NodalSolution;
function f = fcoeffunction(location,state)
N = 1; % Number of equations
nr = length(location.x); % Number of columns
f = zeros(1,nr); % Allocate f
dh=-e*cosd(phi)*sind(location.x+phi)+e*sind(phi)*cosd(location.x+phi);
dt=0.1*omega(e*cosd(phi)*cosd(location.x+phi)+e*sind(phi)*sind(location.x+phi);
o=location.y^2-(L^2/4);
h=C+e*cosd(location.x);
r=(omega*dh+2*dt);
f(1,:)=3*mu*r*o/h^3;
end

Réponses (1)

Ravi Kumar
Ravi Kumar le 12 Nov 2020
The function "fcoeffunction", does not have definitions of e, L, C, mu, r, o, etc. in its scope. Move the definitions in the begining to inside of this function. You can also put a breakpoint on the first line of the function and step through it to find all the missing variable definition.
Regards,
Ravi
  1 commentaire
Jothi Saravanan
Jothi Saravanan le 12 Nov 2020
Hi, I tried doing that but still getting the same error. The value of r and o are computed in the function.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by