Undefined function or variable "t".

19 ビュー (過去 30 日間)
sam
sam 2016 年 6 月 14 日
回答済み: Torsten 2016 年 6 月 14 日
function yourIntegration
tResult = [];
xResult = [];
tStep = [7 14 21 28 35 42 49 56 63 70 77 84];
x0 = [64700 0 0.0033];
for index = 2:numel(tStep)
% Integrate:
beta = 0.43e-08 + (4.28e-08 - 0.43e-08) * exp(-0.20*t(index - 1))
af = @(t,x) f(t, x, beta);
t = tStep(index-1:index);
[t, x] = ode45(af, t, x0);
% Collect the results:
tResult = cat(1, tResult, t);
xResult = cat(1, xResult, x);
% Final value of x is initial value for next step:
x0 = x(end, :);
end
function dx = f(t,x, beta)
dx = [3494-0.054*x(1)-beta*x(1)*x(3); ...
beta*x(1)*x(3) - 0.41*x(2); ...
50000*x(2) - 23*x(3)];
I encountered the error of
Undefined function or variable "t". Error in yourIntegration (line 8) beta = 0.43e-08 + (4.28e-08 - 0.43e-08) * exp(-0.20*t(index - 1))
What should I do?

回答 (1 件)

Torsten
Torsten 2016 年 6 月 14 日
Must read
beta = 0.43e-08 + (4.28e-08 - 0.43e-08) * exp(-0.20*tStep(index - 1))
Best wishes
Torsten.

カテゴリ

Help Center および File ExchangeGeneral PDEs についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by