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 - The Fusion of Science and Community**

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

Loading...

Similar Threads - Need help ODE45 | Date |
---|---|

Matlab Help needed to fix a matlab code | Nov 8, 2017 |

Need help with integral | Dec 23, 2015 |

Need help with maple programming | Nov 20, 2015 |

I need help with Excel | Dec 12, 2014 |

New to mathematica, some basic help needed | May 10, 2014 |

**Physics Forums - The Fusion of Science and Community**