フィルターのクリア

problem with matrix dimension

1 回表示 (過去 30 日間)
Francesco Renzulli
Francesco Renzulli 2021 年 1 月 6 日
回答済み: Walter Roberson 2021 年 1 月 6 日
I have problems with this system,, it returns DG_DX in an ODE 45, but before i can even run ode 45 I have this message
I checked the dimensions of the vectors
C 1x100
A 1x100
rho 100x1
rho_fuel is a scalar
i tried to make fliplr(rho), inside and outside the function, but it gives always the same message
function DG_dx=flux_dim(G,A,rho,C,rho_fuel ,x)
DG_dx=(-C-A).*(rho-rho_fuel);
DG_dx=DG_dx(:);
end

採用された回答

Walter Roberson
Walter Roberson 2021 年 1 月 6 日
You are using a version before R2016b. You will need to code as
DG_dx = bsxfun(@times, (-C-A), (rho-rho_fuel));
The result will be a 100 x 100 matrix, which you will then (:) and return. ode45 will then complain that it is not the same size as the boundary conditions.
Perhaps what you want is instead
DG_dx=(-C-A).'.*(rho-rho_fuel);

その他の回答 (0 件)

カテゴリ

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