Can not pass enough input arguments to BVP function using bvp4c
显示 更早的评论
Hi all,
I'm trying to solve the following BVP function, where lambda will is an unknown and a_r is a constant.
y'' + lambda^2 * y = -lambda^2 * a_r defined in the range [0,L].
BC's are: y(0)=0 and y'(L)=0.
By the guidance of tutorial "Solve BVP with Unknown Parameters" I've written the code below.
lambda=2.5899;
solinit=bvpinit(linspace(0,L,10),@mat4init,lambda);
sol=bvp4c(mat4ode,mat4bc,solinit);
%% functions
function dydx=mat4ode(x,y,lambda)
a_r=3*pi/180;
dthdy=[y(2) -lambda^2*(a_r + y(1))];
end
function res=mat4bc(ya,yb,lambda)
res=[ya(1)
yb(2)];
end
function thinit=mat4init(x)
global L;
thinit=[sin(x*pi/2/L)
(pi/2/L)*cos(x*pi/2/L)];
end
As a result, I am getting this error:
Not enough input arguments.
Error in Untitled6>mat4ode (line 7)
dthdy=[y(2) -lambda^2*(a_r + y(1))];
Error in Untitled6 (line 3)
sol=bvp4c(mat4ode,mat4bc,solinit);
Could you please help me to fix that error?
Thanks
回答(1 个)
Jan
2021-4-24
In the line:
sol=bvp4c(mat4ode,mat4bc,solinit);
you call mat4ode without inputs. You want to provide the function handle instead and append the parameter lambda in addition:
sol=bvp4c(@(t,y) mat4ode(t, y, lambda), mat4bc, solinit);
3 个评论
Abdulkadir Kaya
2021-4-24
Jan
2021-4-25
Two changes:
% solinit = bvpinit(linspace(0,0.6,10), @mat4init, lambda);
solinit = bvpinit(linspace(0,0.6,10), @mat4init);
% And:
% dthdy=[y(2) -lambda^2*(a_r + y(1))];
dydx = [y(2), -lambda^2*(a_r + y(1))];
Abdulkadir Kaya
2021-4-26
类别
在 帮助中心 和 File Exchange 中查找有关 Boundary Value Problems 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!