How to use a data from time series (e.g.) in ode function?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Stephen23
am 20 Feb. 2020
You just need to get the numeric array out of the structure, e.g.:
S = load('GasFlowRate_T.mat', 'Qg');
Qg = S.Qg;
1 Kommentar
Siehe auch
Kategorien
Mehr zu Ordinary Differential Equations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!