ode45 - nonscalar

1 回表示 (過去 30 日間)
John Barr
John Barr 2020 年 4 月 6 日
回答済み: James Tursa 2020 年 4 月 6 日
Does anyone know what's wrong with this code?
F(1) = @(X, T) -50*(X*(1-0.167*(1-X))^0.5 - 2.2*(1-X)/(exp(-11.02+11570/T))/(exp(-14.96+11070/T)+(exp(-1.331+2331/T))*(1-X))^2);
F(2) = @(X, T) -4.1*(T-673.2)+ 10200*(X(1-0.167*(1-X))^0.5 - 2.2*(1-X)/(exp(-11.02+11570/T))/(exp(-14.96+11070/T)+(exp(-1.331+2331/T))*(1-X))^2);
F = F';
initialconditions = [1, 673.2];
zspan = [0 1];
[X,T] = ode45(F, zspan, initialconditions);
I keep on getting the error "Nonscalar arrays of function handles are not allowed; use cell arrays instead." and I'm not sure what it refers to.
  2 件のコメント
madhan ravi
madhan ravi 2020 年 4 月 6 日
編集済み: madhan ravi 2020 年 4 月 6 日
Isn’t this the same question that you asked previously? https://www.mathworks.com/matlabcentral/answers/515898-column-vector-nonscalar-arrays
John Barr
John Barr 2020 年 4 月 6 日
It is not, no, it builds further on that question however.

サインインしてコメントする。

回答 (1 件)

James Tursa
James Tursa 2020 年 4 月 6 日
I suppose you could do something like this instead:
F{1} = etc.
F{2} = etc.
F = F';
f = @(X,T)cell2mat(cellfun(@(c)c(X,T),F,'uni',false));
and then pass f to ode45( ).

カテゴリ

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