필터 지우기
필터 지우기

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 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