Can not pass enough input arguments to BVP function using bvp4c
Ältere Kommentare anzeigen
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
Antworten (1)
Jan
am 24 Apr. 2021
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 Kommentare
Abdulkadir Kaya
am 24 Apr. 2021
Jan
am 25 Apr. 2021
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
am 26 Apr. 2021
Kategorien
Mehr zu Boundary Value Problems finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!