help with bvp4c error
Hello! I am trying to solve a system of four coupled differential equation with two-point boundary conditions. I am getting errors and i am new to this, so i dont understand. Please help me fix it.
function proca_star
clear;
clc;
format long;
infinity = 10;
w=0.817;
x_init=1e-5:0.01:infinity;
global phi_c
for phi_c=[0.394 0.394 0 0]
%solinit = bvpinit(linspace(1e-5,infinity,1000),[1 1 phi_c 0],omega);
solinit = bvpinit(x_init,[1 1 phi_c 0],w);
options = bvpset(‘stats’,’on’,’RelTol’,1e-6);
%condition=true;
%while condition
sol = bvp4c(@bsode,@bsbc,solinit,options);
%condition = sol.stats.maxerr >= 1e-5;
%end
r_data = sol.x;
f = sol.y;
% Plotting the results
figure(1)
plot(r_data, f(1,:));
axis([0 infinity 0 1.5]);
title(‘sigma vs r’)
xlabel(‘r’)
ylabel(‘sigma’)
figure(2)
plot(r_data, f(2,:));
axis([0 infinity -0.5 1]);
title(‘f vs r’)
xlabel(‘r’)
ylabel(‘f’)
figure(3)
plot(r_data, f(3,:));
axis([0 infinity 0 1]);
title(‘m vs r’)
xlabel(‘r’)
ylabel(‘m’)
figure(4)
plot(r_data, f(4,:));
axis([0 infinity -0.5 1.5]);
title(‘g vs r’)
xlabel(‘r’)
ylabel(‘g’)
end
end
% ————————————————————————–
function dfdr = bsode(r, y)
w = 0.817;
N = 1 – 2 * y(3) / r;
dfdr = [4 * pi * r * 0.745 * (y(4)^2 + y(2)^2 / (N^2 * y(1)^2))
w * y(4) – 0.745 * y(1)^2 * N * y(4) / w
4 * pi * r^2 * (((0.745 * y(1)^2 * N^2 * y(4)^2)^2) / (2 * y(1)^2 * w^2) + 0.5 * 0.745 * (y(4)^2 * N + y(2)^2 / (N * y(1)^2)))
r^2 * y(2) * w / (y(1)^2 * N^2) – 2 * y(4)];
end
% ————————————————————————–
function res = bsbc(ya, yb)
global phi_c
res = [ya(1) – 0.394
ya(2) – 0.394
ya(3) – 0
ya(4) – 0
yb(1) – 1
yb(2) – 0
yb(3) – 0.745
yb(4) – 0];
end
Here is the error shown:
Error using proca_star>bsode
Too many input arguments.
Error in bvparguments (line 96)
testODE = ode(x1,y1,odeExtras{:});
Error in bvp4c (line 119)
bvparguments(solver_name,ode,bc,solinit,options,varargin);
Error in proca_star (line 22)
sol = bvp4c(@bsode,@bsbc,solinit,options);Hello! I am trying to solve a system of four coupled differential equation with two-point boundary conditions. I am getting errors and i am new to this, so i dont understand. Please help me fix it.
function proca_star
clear;
clc;
format long;
infinity = 10;
w=0.817;
x_init=1e-5:0.01:infinity;
global phi_c
for phi_c=[0.394 0.394 0 0]
%solinit = bvpinit(linspace(1e-5,infinity,1000),[1 1 phi_c 0],omega);
solinit = bvpinit(x_init,[1 1 phi_c 0],w);
options = bvpset(‘stats’,’on’,’RelTol’,1e-6);
%condition=true;
%while condition
sol = bvp4c(@bsode,@bsbc,solinit,options);
%condition = sol.stats.maxerr >= 1e-5;
%end
r_data = sol.x;
f = sol.y;
% Plotting the results
figure(1)
plot(r_data, f(1,:));
axis([0 infinity 0 1.5]);
title(‘sigma vs r’)
xlabel(‘r’)
ylabel(‘sigma’)
figure(2)
plot(r_data, f(2,:));
axis([0 infinity -0.5 1]);
title(‘f vs r’)
xlabel(‘r’)
ylabel(‘f’)
figure(3)
plot(r_data, f(3,:));
axis([0 infinity 0 1]);
title(‘m vs r’)
xlabel(‘r’)
ylabel(‘m’)
figure(4)
plot(r_data, f(4,:));
axis([0 infinity -0.5 1.5]);
title(‘g vs r’)
xlabel(‘r’)
ylabel(‘g’)
end
end
% ————————————————————————–
function dfdr = bsode(r, y)
w = 0.817;
N = 1 – 2 * y(3) / r;
dfdr = [4 * pi * r * 0.745 * (y(4)^2 + y(2)^2 / (N^2 * y(1)^2))
w * y(4) – 0.745 * y(1)^2 * N * y(4) / w
4 * pi * r^2 * (((0.745 * y(1)^2 * N^2 * y(4)^2)^2) / (2 * y(1)^2 * w^2) + 0.5 * 0.745 * (y(4)^2 * N + y(2)^2 / (N * y(1)^2)))
r^2 * y(2) * w / (y(1)^2 * N^2) – 2 * y(4)];
end
% ————————————————————————–
function res = bsbc(ya, yb)
global phi_c
res = [ya(1) – 0.394
ya(2) – 0.394
ya(3) – 0
ya(4) – 0
yb(1) – 1
yb(2) – 0
yb(3) – 0.745
yb(4) – 0];
end
Here is the error shown:
Error using proca_star>bsode
Too many input arguments.
Error in bvparguments (line 96)
testODE = ode(x1,y1,odeExtras{:});
Error in bvp4c (line 119)
bvparguments(solver_name,ode,bc,solinit,options,varargin);
Error in proca_star (line 22)
sol = bvp4c(@bsode,@bsbc,solinit,options); Hello! I am trying to solve a system of four coupled differential equation with two-point boundary conditions. I am getting errors and i am new to this, so i dont understand. Please help me fix it.
function proca_star
clear;
clc;
format long;
infinity = 10;
w=0.817;
x_init=1e-5:0.01:infinity;
global phi_c
for phi_c=[0.394 0.394 0 0]
%solinit = bvpinit(linspace(1e-5,infinity,1000),[1 1 phi_c 0],omega);
solinit = bvpinit(x_init,[1 1 phi_c 0],w);
options = bvpset(‘stats’,’on’,’RelTol’,1e-6);
%condition=true;
%while condition
sol = bvp4c(@bsode,@bsbc,solinit,options);
%condition = sol.stats.maxerr >= 1e-5;
%end
r_data = sol.x;
f = sol.y;
% Plotting the results
figure(1)
plot(r_data, f(1,:));
axis([0 infinity 0 1.5]);
title(‘sigma vs r’)
xlabel(‘r’)
ylabel(‘sigma’)
figure(2)
plot(r_data, f(2,:));
axis([0 infinity -0.5 1]);
title(‘f vs r’)
xlabel(‘r’)
ylabel(‘f’)
figure(3)
plot(r_data, f(3,:));
axis([0 infinity 0 1]);
title(‘m vs r’)
xlabel(‘r’)
ylabel(‘m’)
figure(4)
plot(r_data, f(4,:));
axis([0 infinity -0.5 1.5]);
title(‘g vs r’)
xlabel(‘r’)
ylabel(‘g’)
end
end
% ————————————————————————–
function dfdr = bsode(r, y)
w = 0.817;
N = 1 – 2 * y(3) / r;
dfdr = [4 * pi * r * 0.745 * (y(4)^2 + y(2)^2 / (N^2 * y(1)^2))
w * y(4) – 0.745 * y(1)^2 * N * y(4) / w
4 * pi * r^2 * (((0.745 * y(1)^2 * N^2 * y(4)^2)^2) / (2 * y(1)^2 * w^2) + 0.5 * 0.745 * (y(4)^2 * N + y(2)^2 / (N * y(1)^2)))
r^2 * y(2) * w / (y(1)^2 * N^2) – 2 * y(4)];
end
% ————————————————————————–
function res = bsbc(ya, yb)
global phi_c
res = [ya(1) – 0.394
ya(2) – 0.394
ya(3) – 0
ya(4) – 0
yb(1) – 1
yb(2) – 0
yb(3) – 0.745
yb(4) – 0];
end
Here is the error shown:
Error using proca_star>bsode
Too many input arguments.
Error in bvparguments (line 96)
testODE = ode(x1,y1,odeExtras{:});
Error in bvp4c (line 119)
bvparguments(solver_name,ode,bc,solinit,options,varargin);
Error in proca_star (line 22)
sol = bvp4c(@bsode,@bsbc,solinit,options); bvp4c, boundary value problem, coupled odes, error MATLAB Answers — New Questions