why ode45 can not substitute y(2) with initial value
1 view (last 30 days)
Show older comments
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 Comment
Answers (1)
Jan
on 19 Mar 2013
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 Comments
See Also
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!