Error occurring while solving odes using ode15s

4 visualizaciones (últimos 30 días)
Telema Harry
Telema Harry el 1 de Ag. de 2021
Comentada: Telema Harry el 3 de Ag. de 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.
  10 comentarios
Telema Harry
Telema Harry el 3 de Ag. de 2021
Thank you once again for your help. Please see below output of the code.
class(tspan) = 'double'
class(In0) = double
class (wind) = struct
class (I) = struct
class(B) = struct
class(DATE) = struct
class (test_output) = double
Telema Harry
Telema Harry el 3 de Ag. de 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.

Iniciar sesión para comentar.

Respuestas (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov el 1 de Ag. de 2021
Editada: Sulaymon Eshkabilov el 1 de Ag. de 2021
The computed solution might be "nan" or "inf" only. Briefly speaking the size mismatch.
  2 comentarios
Walter Roberson
Walter Roberson el 1 de Ag. de 2021
I do not understand how this could explain the error message about trying to mix sparse and single in a * operation ?
Telema Harry
Telema Harry el 2 de Ag. de 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.

Iniciar sesión para comentar.

Categorías

Más información sobre Ordinary Differential Equations en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by