I searched a solution for some time and it seems that I was doing everything right but the error
Error using odearguments (line 110) Inputs must be floats, namely single or double.
Keeps appearing. Any ideas what I am doing wrong with ode23?
Tc = 60/72;
Ts = (2/5)*Tc;
R=1.05;
C=1.066;
syms ti q
IO = solve(90-int(q * (sin(pi*ti/Ts)),ti,0,Ts),q);
IO = subs(IO, 3.14, pi);
sine = @(t) sin (pi*t/Ts);
i = @(t) IO * sine(t).*(t <= Ts);
for n=1:5
if (n==1)
P_ss2 = 80;
end
t = (n-1)*Tc:0.01:n*Tc;
I = @(t) IO *sine(t-(n-1)*Tc).*(t <= ((n-1)*Tc+Ts));
z2 = @(t,y2) (-y2/(R*C)+I(t)/C);
[t_m2, P_m2] = ode23(z2, [(n-1)*Tc n*Tc], P_ss2);
P_ss2 = P_m2(end);
end

 채택된 답변

Torsten
Torsten 2016년 3월 17일
편집: Torsten 2016년 3월 17일

0 개 추천

Tc=60/72;
Ts=(2/5)*Tc;
R=1.05;
C=1.066;
I0=45*pi/Ts;
P_ss2=80;
for n=1:5
func=@(t,y)(-y/R+I0*sin(pi*(t-(n-1)*Tc)/Ts)*(t <= ((n-1)*Tc+Ts)))/C;
[t_m2, P_m2] = ode23(func, [(n-1)*Tc n*Tc], P_ss2);
P_ss2 = P_m2(end);
end
Best wishes
Torsten.

추가 답변 (2개)

Torsten
Torsten 2016년 3월 17일

0 개 추천

Mixing of symbolic and numeric variables is not allowed when using ode23: z2 must be a function handle of a purely numeric expression (which is not the case for I(t)).
Best wishes
Torsten.

댓글 수: 1

pisau nx
pisau nx 2016년 3월 17일
Is there a easy solution for that? I need that I(t) function there.

댓글을 달려면 로그인하십시오.

Aida Naranjo
Aida Naranjo 2019년 1월 12일

0 개 추천

You should put double() in the function, I have a similar code and it works.
z2 = @(t,y2) double((-y2/(R*C)+I(t)/C));

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

질문:

2016년 3월 17일

답변:

2019년 1월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by