Unrecognized function error in bvp4c (in boundary conditions)
Show older comments
I have a diiferential equation:

where f(r) is known and interpolated with same mesh size.
Boundary conditions:
I have implemeted bvp4c using matlab documentation:
A = 2;
B = 1.5;
load('gr_in.mat');
rc = gr(:,2);
N = 100;
r = linspace(rc(1),rc(end),N);
fr = interp1(gr(:,2),gr(:,1),r,'spline');
fr=fr';
opts = bvpset('FJacobian',@jac,'RelTol',0.01,'AbsTol',0.01,'Stats','on');
rmesh = linspace(rc(1), rc(end), N);
solinit = bvpinit(rmesh, [1; 1]);
sol = bvp5c(@(r,y) bvpfcn(r,y,A,B,fr), bcfcn(ya,yb), solinit, opts);
function dydr = bvpfcn(r,y,A,B,fr) % equation to solve
dydr = [y(2)
-2*y(2)/r+A*y(1)-B*fr];
end
%---------------------------------
function res = bcfcn(ya,yb) % boundary conditions
res = [ya(1)-1
yb(1)];
end
%---------------------------------
function dfdy = jac(r,y,A) % analytical jacobian for f
dfdy = [0 1
A -2/r];
end
I get following error:
Unrecognized function or variable 'ya'.
Error in Untitled (line 11)
sol = bvp5c(@(r,y) bvpfcn(r,y,A,B,fr), bcfcn(ya,yb), solinit, opts);
Accepted Answer
More Answers (0)
Categories
Find more on Numerical Integration and Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
