why ode45 can not substitute y(2) with initial value
1 次查看(过去 30 天)
显示 更早的评论
function dy = Weeq(t,y)
global K rs rr zpgs Tm Te Wm Pd global Ivdot Igdot Iedot C
Wg = y(2).*(zpgs+1) - y(1).*zpgs
eq1Tm = ((rr+rs).^(2)./(rr.*Iedot) + rs.^(2)./(rr.*Igdot));
eq1Te = (rr+rs)./Iedot;
eq1Tg = rs./Igdot;
eq1C = ((rr+rs).^(2)./(rr.*Iedot.*K) + rs.^(2)./(rr.*Igdot.*K));
eq1Wr = (Ivdot.*(rr+rs).^(2)./(rr.*Iedot.*K) + Ivdot.*rs.^(2)./(rr.*Igdot.*K)+rr);
Tg = (Pd - Tm.*Wm -Te.* y(2))./Wg
eq1 = (eq1Tm.*Tm + eq1Te.*Te + eq1Tg.*Tg - eq1C.*C)./eq1Wr;
eq2Tm = K.*rr./Ivdot;
eq2Te = rr^(2).*K./((rr+rs).*Ivdot) + (rs^(2)./((rr+rs).*Igdot));
eq2Tg = rs./Igdot;
eq2C = rr./Ivdot;
eq2We = rr^(2).*K.*Iedot./((rr+rs).*Ivdot) + (rs^(2).*Iedot./((rr+rs).*Igdot)) + rr + rs;
eq2 = (eq2Tm.*Tm + eq2Te.*Te - eq2Tg.*Tg - eq2C.*C)./eq2We;
dy=[eq1 ; eq2]
---------
sim.m file
Wei = 80.935 Wri = 58.453 Tm = [5] Te = 60 S = 1
[t,y] = ode15s(@Weeq,[0,100],[Wri; Wei])
then result is
Wei =
80.9350
Wri =
58.4530
Tm =
5
Te =
60
S =
1
Tg =
[]
dy =
[]
Error using odearguments (line 93) WEEQ returns a vector of length 0, but the length of initial conditions vector is 2. The vector returned by WEEQ and the initial conditions vector must have the same number of elements.
Error in ode15s (line 149) [neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...
Error in ode (line 34) [t,y] = ode15s(@Weeq,[0,100],[Wri; Wei])
why matlab cannot replace y(2) with initial value for evaluating Tg??? if true % code end
回答(1 个)
Jan
2013-3-19
When any of the (too!) many global variables is empty, the result of the computations can be empty also. So please use the debugger (set a break point) to check the values of:
K rs rr zpgs Tm Te Wm Pd
Ivdot Igdot Iedot C
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!