# Error occurring while solving odes using ode15s

2 views (last 30 days)
Telema Harry on 1 Aug 2021
Commented: Telema Harry on 3 Aug 2021
Hello,
I am trying to solve a systems of nonlinear ODE using ODE15s but I keep getting an error after about 29 seconds and I can't figure out what is causing the error.
see a screen shot of the error.
What could be the likely cause of this error.
Telema Harry on 3 Aug 2021
@Walter Roberson Thank you so much for the recommendation on how to pass additional variables to the ode*().
I have removed all the global variables and I have re-written my function as shown below.
In0 = [loc.lat; loc.lon; In.T_gas; In.T_film; In.M_gas; In.Uz; In.Z];
[t, output] = Balloondynamics(tspan,In0,wind, DATE, I, B);
function [time, dxdt] = dynamics(tspan,y0,wind, DATE, I, B)
[time, dxdt] = ode23(@solve_ode,tspan,y0);
function dxdt = solve_ode(t,y)
%% TRANSFER VALUES FROM y VARIABLE TO THE ACTUAL VARIABLE NAMES
lat = y(1);
lon = y(2);
T_gas = y(3);
T_film = y(4);
M_gas = y(5);
Uz = y(6);
Z = y(7);
[t,y']
....
end
end
I am a step closer to solving my next challenge.
So, my wind data for 1 hour is about 6.5 G and loading it takes a lot of time. Idealy, I will like to run my simulation using 1 week worth of wind data. This would mean, discarding the wind data after 1 hour simulation time (3600 seconds) and loading the next hour wind data.
e.g. load new wind data after every 3600 seconds.
I can read the wind data one after the other but I am not sure how to pass it to the ode function.
However, I was able to pass the multiple wind data to my own Runge Kutta function.

Sulaymon Eshkabilov on 1 Aug 2021
Edited: Sulaymon Eshkabilov on 1 Aug 2021
The computed solution might be "nan" or "inf" only. Briefly speaking the size mismatch.
##### 2 CommentsShowHide 1 older comment
Telema Harry on 2 Aug 2021
Thank you for your input @Sulaymon Eshkabilov
I initially thought that maybe one of the computed solution is "nan" or infinity, so I tried to debug the code just before it crashed and I discovered that all the computed solutions were all real numbers.

### Categories

Find more on Programming in Help Center and File Exchange

R2021a

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!