Error occurring while solving odes using ode15s

1 次查看(过去 30 天)
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 个评论
Telema Harry
Telema Harry 2021-8-3
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 2021-8-3
@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.

请先登录,再进行评论。

回答(1 个)

Sulaymon Eshkabilov
编辑:Sulaymon Eshkabilov 2021-8-1
The computed solution might be "nan" or "inf" only. Briefly speaking the size mismatch.
  2 个评论
Walter Roberson
Walter Roberson 2021-8-1
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 2021-8-2
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

标签

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by