Column Vector - Nonscalar arrays.

5 ビュー (過去 30 日間)
John Barr
John Barr 2020 年 4 月 6 日
コメント済み: James Tursa 2020 年 4 月 6 日
Hello;
For some reason I can't put the following equations into a column vector:
F1 = @(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);
F2 = @(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 = [F1; F2]
unfortunately I keep on getting the error:
Nonscalar arrays of function handles are not allowed; use cell arrays instead.
Does anyone know how to format the two equations nicely into a column vector (So that I can run ODE45 afterwards with it)
Thanks

回答 (1 件)

James Tursa
James Tursa 2020 年 4 月 6 日
F = @(X, T) [F1(X, T); F2(X, T)];
  3 件のコメント
John Barr
John Barr 2020 年 4 月 6 日
Thanks, but when I run the code to solve the differential equations as shown below it then says that the vector is only of length 1.
F1 = @(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);
F2 = @(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 = @(X,T) [F1(X,T); F2(X,T)];
initialconditions = [1 673.2];
zspan = [0 1];
[X,T] = ode45(@(X,T) F, zspan, initialconditions);
James Tursa
James Tursa 2020 年 4 月 6 日
This
[X,T] = ode45(@(X,T) F, zspan, initialconditions);
should be simply this
[X,T] = ode45(F, zspan, initialconditions);

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

カテゴリ

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