フィルターのクリア

How to load a big .txt-file while using ode45

1 回表示 (過去 30 日間)
Hekseli
Hekseli 2013 年 9 月 27 日
回答済み: Hekseli 2013 年 9 月 27 日
Hey!
I am solving a differential equation system with ode45 solver and the problem is that one of the derivatives demands a constant parameter from a big matrix (5x500000), depending on the previous step values in vector x. I can't load the matrix in a differential equation function because then it will be called multiple times and loading takes time.
So where / how should I load this big matrix?
A quick example would be something like this.
function1
[T, X]=ode45(@differ,[0 1],[1 1 1 1]); plot(X(:,1),X(:,2)); hold on;
end
function f = differ(t, x) %x=(x1 x2 x3 4)
A=load('file.txt'); %Now this is not efficient g=9.81;
f = zeros(4,1); f(1) = x(3); f(2) = x(4); f(3) = 0; f(4) = -g*A(i,j); %Here i and j will be determined according to values in x(1) and x(2)
end

回答 (1 件)

Hekseli
Hekseli 2013 年 9 月 27 日
Global variable seems to offer somekind of solution but I can't believe that it is the most efficient one...

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by