How to use a data from time series (e.g.) in ode function?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi, i want to use data from another mat file which contains a timeseries, below is a simplified example:
tspan = [0 5];
y0 = 0;
tQ = linspace(0,5,25);
Qg = load('GasFlowRate_T.mat', 'Qg');
[t y] = ode45(@(t,y) f(t,y,tQ,Qg),tspan,y0);
plot(t,y)
function dydt = f(t,y,tQ,Qg)
Qg = interp1(tQ, Qg, t);
dydt = Qg*t;
end
and i will get the error:
Error using interp1>reshapeValuesV (line 439)
Values V must be of type double or single.
Error in interp1>reshapeAndSortXandV (line 419)
[V,orig_size_v] = reshapeValuesV(V);
Error in interp1 (line 93)
[X,V,orig_size_v] = reshapeAndSortXandV(varargin{1},varargin{2});
but i also couldn't convert from struct to double, how could i exactly to use the data from timeseries?
0 comentarios
Respuestas (1)
Stephen23
el 20 de Feb. de 2020
You just need to get the numeric array out of the structure, e.g.:
S = load('GasFlowRate_T.mat', 'Qg');
Qg = S.Qg;
Ver también
Categorías
Más información sobre Ordinary Differential Equations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!