problem with matrix dimension

1 visualizzazione (ultimi 30 giorni)
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

Risposta accettata

Walter Roberson
Walter Roberson il 6 Gen 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);

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by