Additional Inputs PDE Toolbox f coefficient

3 ビュー (過去 30 日間)
ADSW121365
ADSW121365 2020 年 3 月 4 日
編集済み: ADSW121365 2020 年 4 月 22 日
My code below is generating some sort of error, however I'm not sure the error message is consistent with the problem which is actually occuring. The aim is to input additional parameters to the f-coefficient in the PDEToolbox:
function f = f_coeffunction_3v(location,~,N_w,mag)
N = 3; % Number of equations
nr = length(location.x); % Number of columns
f = zeros(N,nr); % Allocate f
Quad = zeros(1,nr);
Quad(1:10) = 1;
Quad(12:end) = 2;
jo = N_w.*mag ./ 2; %Current Density Magnitude
f(1,Quad == 1) = jo; f(2,Quad == 1) = 0 ; f(3,Quad == 1) = 0 ;
f(1,Quad == 2) = 0 ; f(2,Quad == 2) = jo; f(3,Quad == 2) = 0 ;
end
N_w = 4; mag = 1;
f_fun = @(location,state)f_coeffunction_3v(location,state,N_w,mag); %Assign handle with correct functional form
f_vals = f_fun(location,[]); %Test values - identical to those from _2v.
specifyCoefficients(model,'m',0,'d',0,'c',c_coeff,'a',0,'f',@f_fun,'Cell',1);
Error using pde.CoefficientAssignment/checkCoefFcnHdlArgCounts (line 499)
Function specifying a coefficient must accept two
input arguments and return one output argument.

採用された回答

Ravi Kumar
Ravi Kumar 2020 年 3 月 4 日
Change to:
specifyCoefficients(model,'m',0,'d',0,'c',c_coeff,'a',0,'f',f_fun,'Cell',1);
Remove the @ symbol in front of f_fun, because you already created f_fun as function_handle when you defined it.
Regards,
Ravi
  1 件のコメント
ADSW121365
ADSW121365 2020 年 3 月 4 日
I knew it was something dumb! Thanks.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGeometry and Mesh についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by