problem with matrix dimension

1 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by