Hello, so I was practicing the shooting method using this script:
function Shooting_Conoption=odeset('RelTol',1e-3)s=-200:20:200s0=[]ncase=length(s)b=zeros(1,ncase)for i=1:ncase [z,c]=ode23s(@mandela,[0 0.001],[0.2 s(i)],option) %zrange= 0 to 0.001
[m,n]=size(c) b(1,i)=c(m,2)endy0=interp1(b,s,0)global k Dabk=.001Dab=(1.2e-9)L=.001x=L*sqrt(k/Dab)[z c]=ode45(@mandela,[0 0.001],[0.2 y0],option)C=0.2*(cosh(x*(1-z/L))/cosh(x))plot(z,C,'r',z,c(:,1),'ko')legend('Exact','Differential')xlabel('z')ylabel('Concentration')grid onfunction dCadz=mandela(z,c)global k DabdCadz=[c(2);((k/Dab)*c(1))]
but when I run it, it returns these errors: Error using odearguments (line 92) MANDELA returns a vector of length 1, but the length of initial conditions vector is 2. The vector returned by MANDELA and the initial conditions vector must have the same number of elements.
Error in ode23s (line 121) = odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in class_0323 (line 8) [z,c]=ode23s(@mandela,[0 0.001],[0.2 s(i)],option) but I have two things in my dCadz function so I don't understand why I am only getting back 1 value when there are two things. :/ I need some serious help.
Best Answer