Clear Filters
Clear Filters

problem with matrix dimension

1 view (last 30 days)
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

Accepted Answer

Walter Roberson
Walter Roberson on 6 Jan 2021
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);

More Answers (0)

Community Treasure Hunt

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

Start Hunting!