function[]=shooting()
global R0 Dim r_inf dr_Taylor tol sigma options
Dim =2; sigma =1; r_int =15; dr=0.001; tol=1e-10;
dr_Taylor=1e-6;
R0_guess = 2.2;
options = odeset('RelTol',tol,'AbsTol',tol);
R0 = fzero(@shoot_for_R0,R0_guess);
X0 = [R0 0 0 0 0];
[r_sol,X]=ode45(@R_profile,[0:dr:r_inf], X0, options);
R_sol = X(:,1); dR_sol=X(:,2);
plot(r_sol,R_sol,r_sol,dR_sol);legend('R','dR');xlabel('r'); shg
I_R2 = X(end, 3); I_dR2 = X(end,4); I_2sigFZERO cannot continue because user-supplied function_handle ==> shoot_for_R0 failed with the error belowma_2 = X(end,5);
Pohozaev1 = IR2-(2-sigma*(Dim-2))/2/(sigma+1)*I_2sigma_2
Pohozaev2 = I_dR2-sigma*Dim/2/(sigma+1)*I_2sigma_2
end
function R_inf = shoot_for_R0(R0)
global r_inf options
X0 = [R0 0 0 0 0];
[r_sol,X]=ode45(@R_profile, [0 r_inf], X0, options);
R_inf = X(end,1);
end
function dX = R_profile(r,X)
global dr_Taylor R0 Dim sigma
R = X(1); dR = X(2); dx = zeros(5,1); dX(1) = dR;
R_2sigma = abs(R)^(2*sigma);
if (r >= dr_Taylor)
dX(2) = R-R_2sigma*R-(Dim-1)*dR/r;
else
if isempty(R0)==1
R0=0;
end
ddR0 = R0*(1-abs(R0)^(2*sigma))/Dim;
dX(2) = R-R_2sigma*R-(Dim-1)*ddR0;
end
dX(3) = r^(Dim-1)*R^2;
dX(4) = r^(Dim-1)*dR^2;
dX(5) = r^(Dim-1)*R_2sigma*R^2;
end
Error using fzero>localFirstFcnEval (line 729)
FZERO cannot continue because user-supplied function_handle ==> shoot_for_R0 failed with the error below.
When the first argument to ode45 is a function handle, the tspan argument must have at least two elements.
Error in fzero (line 286)
fx = localFirstFcnEval(FunFcn,FunFcnIn,x,varargin{:});
Error in townes (line 9)
R0 = fzero(@shoot_for_R0,R0_guess);