On 1/13/20 8:54 AM, Bala Vignesh wrote:

> I am trying to solve ODE equation inside a for loop for a given mdot, Ab and

> time step. I am getting error .. can anyone help me please

>

> Code:

> rhop=1765;

> a_burn=2.6292e-5;

> n=0.33;

> a=1577.1;

> Ath=0.008167;

> a=1577.1;

> b=9e-7;

> gamma=0.6465;

> Vc=0.0943;

> pc0=0;

> %

> %Read excel files

> A=xlsread('Ignition transient.xlsx');

> m=A(:,7);

> tspan=A(:,4);

> Area=A(:,6);

> for i=2:40

> mdot=m(i)

> Ab=Area(i)

> [t,Pc]= ode45(@(t,Pc)

> (mdot+(rhop*Ab*a*Pc^n)-(Pc(i)*Ath/(a+(b*Pc))))*(gamma^2*(a+(b*Pc))^3/(Vc*(a-(b*Pc)))),

> tspan, 0);

> end

>

> Error message:

> error: Pc(2): out of bound 1

> error: called from

> ignitionTransient>@<anonymous> at line 29 column 69

> starting_stepsize at line 46 column 5

> ode45 at line 192 column 25

> ignitionTransient at line 29 column 7

>

On quick perusal, I don't see the definition of Pc, so maybe you just

need to initialize it to the correctly sized array.

In order to get further help, please try to minimize your example so

that it's self-contained (e.g. you (and I) can run it by pasting it into

a fresh instance of Octave).