How to pass a control parameter to feval() in a loop?

1 回表示 (過去 30 日間)
Vedasri Godavarthi
Vedasri Godavarthi 2017 年 9 月 25 日
回答済み: Star Strider 2017 年 9 月 25 日
I need to feval() to take the arguments in a loop. I meant to say there is an ode function f(t,y,mu). mu is varied in each loop. So when I run feval(@ode45,@f,1:100,[1,0,0],0). I run into an error

回答 (1 件)

Star Strider
Star Strider 2017 年 9 月 25 日
’... I run into an error’
Not surprisingly.
There is no reason to use feval with ode45 when you are passing parameters to your ODE function.
See if something similar to:
for k1 = 1:something
mu = mu_vector(k1);
[T{k1},X{k1}] = ode45(@(t,x) f(t,x,mu), 1:100, [1,0,0]);
end
will do what you want.

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by