PDE toolbox, specifying coefficients, error telling me "Function specifying a coefficient must accept two input arguments and return one output argument."
조회 수: 1 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
답변 (1개)
Ravi Kumar
2020년 11월 12일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 General PDEs에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!