error ode arguments (line 92)
Show older comments
Hello, so I was practicing the shooting method using this script:
function Shooting_Con
option=odeset('RelTol',1e-3)
s=-200:20:200
s0=[]
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)
end
y0=interp1(b,s,0)
global k Dab
k=.001
Dab=(1.2e-9)
L=.001
x=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 on
function dCadz=mandela(z,c)
global k Dab
dCadz=[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.
Accepted Answer
More Answers (0)
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!