Error occurring while solving odes using ode15s

조회 수: 2 (최근 30일)
Telema Harry
Telema Harry 2021년 8월 1일
댓글: Telema Harry 2021년 8월 3일
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일
편집: 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