Clear Filters
Clear Filters

error using ode23

1 view (last 30 days)
nune pratyusha
nune pratyusha on 27 Apr 2021
Commented: Jan on 27 Apr 2021
function dydt = parasi12(t1,y1)
a=7.2*10^-6;
Gm=2.5*10^-2;
Sp=2.75*10^-5;
yon=6*10^-2;
b=4.7;
son=4.5*10^-1;
B=10^-4;
vm=0.1:0.001:0.2;
gp=sinh(vm);
A=10^-10;
soff=1.3*10^-2;
beta=500;
e1=52;
e2=55;
s=10*10;
D=20;
yoff=1.3*10^-2;
f=50;
v1=sawtooth(2*pi*f*t1);
% v=v+1;
i1=v1.*(y1*Gm+(1-y1)*a.*exp(b*sqrt(gp)));
p1=i1.*v1;
dydt = B*sinh(v1/son).*exp(-y1.^2/yon^2).*exp(p1/Sp).*heaviside(v1)+...
A*sinh(v1/soff).*exp(-yoff^2./(y1.^2)).*exp(1/(1+(beta*p1))).*heaviside(-v1);
vm=0.1:0.001:0.2;
t1=0.01:0.0009:0.1;
[t1,y1] = ode23(@parasi12,t1,0.01)
e1=52;
e2=55;
s=10*10;
D=20;
a=7.2*10^-6;
Gm=2.5*10^-2;
b=4.7;
sp=2.75*10^-5;
yon=6*10^-2;
son=4.5*10^-1;
B=10^-4;
A=10^-10;
soff=1.3*10^-2;
beta=500;
yoff=1.3*10^-2;
gp=tanh(vm);
f=50;
v1=sawtooth(2*pi*f*t1);
plot(t1,y1)
in command window error is coming like
Error using /
Matrix dimensions must agree.
Error in parasi12 (line 25)
A*sinh(v1/soff).*exp(-yoff^2./(y1.^2)).*exp(1/(1+(beta*p1))).*heaviside(-v1);
Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode23 (line 114)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in Untitled3 (line 3)
[t1,y1] = ode23(@parasi12,t1,0.01)
>>
  2 Comments
nune pratyusha
nune pratyusha on 27 Apr 2021
i want y values but replace of / with ./ is not working.
Jan
Jan on 27 Apr 2021
As said already: The readers have no chance to know, if your code matchs the mathematical formula. So we cannot debug the code with onbly knowing that there is a bug anywhere.
Use the debugger to step through your code line by line to examine, what's going on.

Sign in to comment.

Answers (1)

Jan
Jan on 27 Apr 2021
dydt = B * sinh(v1 / son) .* exp(-y1.^2 ./ yon^2) ...
.* exp(p1 ./ Sp) .* heaviside(v1) + ...
A * sinh(v1 / soff) .* exp(-yoff^2 ./ (y1.^2)) ...
.* exp(1 ./ (1 + (beta * p1))) .* heaviside(-v1);
I've replaced all / by ./ for an elementwise division. But without seeing the formula, which you want to calculate, this is pure guessing only. In general it is impossible to fix code only by seeing the failing code. The comments are missing.
By the way, 4.5*10^-1 is a multiplication and an expensive power operation, while 4.5e-1 is a cheap constant. Therefore this simpler notation is not only easier to read, but faster also.

Categories

Find more on Programming in Help Center and File Exchange

Tags

Products


Release

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!