I'm stuck with a problem with the subfunction ODE45 of Matlab:(adsbygoogle = window.adsbygoogle || []).push({});

I need to save two matrixes' values created inside the ODE subfunction.

I can't create an index inside the subfunction because I have to define it at the start so at every round it returns to zero.

This is what I've done in the main:

t0 = 0;

tf = 450;

y0 = [0 0 0 0 0 0];

options = odeset('RelTol', 1e-6);

[t, y] = ode45('ac_im3_IPM_prova1', [t0,tf] , y0, options);

and this is the subfunction:

function yp = ac_im3_IPM_prova1(t, y);

.

.

.

vsd = 2/3 * (vsa * cos(ttg) + vsb * cos(ttg - 2*pi/3) + vsc * cos(ttg - 4*pi/3));

vsq = -2/3 * (vsa * sin(ttg) + vsb * sin(ttg - 2*pi/3) + vsc * sin(ttg - 4*pi/3));

.

.

.

yp(1) = (vsd - Rs*isd + (wge)*fsq);

yp(2) = (vsq - Rs*isq - (wge)*fsd);

yp(3) = ( - Rr*ird + (wge-p*wm)*frq);

yp(4) = ( - Rr*irq - (wge-p*wm)*frd);

yp(5) = (tm - (TL + KD*wm)) / J;

yp(6) = wge;

yp = yp';

I'd like to save vsd and vsq values of every round in a matrix or in someway!

**Physics Forums | Science Articles, Homework Help, Discussion**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Need help for ODE45 matlab

**Physics Forums | Science Articles, Homework Help, Discussion**