필터 지우기
필터 지우기

Problem with initial condition

조회 수: 3 (최근 30일)
Francesco Renzulli
Francesco Renzulli 2021년 1월 6일
답변: Aditya Shah 2022년 6월 6일
When I run ode I get the eerror message "@(X,G)FLUX_DIM(C,RHO_FUEL,A,RHO,X,G) returns a vector of length 100, but the length of initial conditions vector
is 300. The vector returned by @(X,G)FLUX_DIM(C,RHO_FUEL,A,RHO,X,G) and the initial conditions vector must have
the same number of elements.
Np =300;
x=linspace(0,L_grain,Np) ;
x=x(:);
x_0=zeros(1,Np);
x_0=x_0(:);
[x_sol,G_sol]=ode45(@(x,G)flux_dim(C,rho_fuel,A,rho,x,G),[0,L_grain],x_0);
function DG_dx=flux_dim(x,A,rho,C,rho_fuel,G)
DG_dx=(-C-A).'.*(rho-rho_fuel);
DG_dx=DG_dx(:);
end
  댓글 수: 4
Mathieu NOE
Mathieu NOE 2021년 1월 7일
tried to run your code but many constants are missing
even thougt x and G are in the function args they are not used in the DE
Francesco Renzulli
Francesco Renzulli 2021년 1월 7일
I know i didn't pubblish all the code because it is long, maybe the problem is rho, that is a solution fromm another ODE45

댓글을 달려면 로그인하십시오.

답변 (1개)

Aditya Shah
Aditya Shah 2022년 6월 6일
Hi!
The problem seems to have occurred due to a mismatch between the size of the output vector of the function FLUX_DIM and the size of the initial conditions vector.
I am assuming the size of the following variable as:
C: 1x100
A: 1x100
rho: 100x1
rho_fuel: scalar
Correcting the size of initial condition by changing the value of variable Np to 100, solves the problem.
Please note the size of variable was referred from the following Matlab Answer post:

카테고리

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