Error: starting_stepsize
Show older comments
I get an error and my code is at below
error: starting_stepsize: operator /: nonconformant arguments (op1 is 1x1, op2 is 1x2)
error: called from
starting_stepsize at line 55 column 8
ode45 at line 192 column 25
kpri at line 17 column 8
My code is at below
Fao=5;
ep=0;
d=[0.01:2];
kprime=3.*(3./(60.*d).^2).*(((60.*d).*coth(60.*d.*pi./180))-1);
alpha0=0.8*10^-4./d;
Cao=0.207;
DEs=@(W,xy) [(((Cao.*(1-xy(1)).*xy(2)).^2/Fao).*kprime); (-alpha0./(2.*xy(2)))];
xy=[0,1];
Wspan=linspace(0,100,5);
[W,xy] = ode45(DEs,Wspan,xy);
figure(1)
plot(W, xy)
grid
legend('x(W)', 'y(W)')
Answers (1)
@Buey Cande See the following changes to your code
Fao=1.5;
%ep=0;
d=[0.1:0.25:1];
kprime=3.*(3./(60.*d).^2).*(((60.*d).*coth(60.*d.*pi./180))-1);
alpha0=0.8*10^-4./d;
Cao=0.567;
y0=[0 1];
Wspan=[0 5];
figure(1)
hold on
for k = 1:numel(kprime)
[W,y] = ode45(@(W,y) DEs(Cao,Fao,kprime(k),alpha0(k),W,y),Wspan,y0);
plot(W, y,'linewidth',2)
end
function dey = DEs(Cao,Fao,kprime,alpha0,W,y)
dey = zeros(2,1);
dey(1) = ((Cao.*(1-y(1)).*y(2)).^2)/Fao.*kprime;
dey(2) = (-alpha0./(2.*y(2)));
end
axis([0 5 0 0.95])
grid
%legend('x(W)', 'y(W))
Categories
Find more on Chemistry in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!