2010-07-24 9 views

답변

7

먼저 주문을 줄여야합니다. (M = ZY])

: Z = Y '=> Z'= Y "

내 ODE 다음 이제이 ODE를 나타내는 MATLAB의 함수를 작성할 수

z' = sqrt(-2*z - 3*y + sin(x)), with z(0) = 0 
y' = z, with y(0) = 1 

된다하자 다음과 같이

function dMdx = odefunc(x,M) 
    z = M(1); 
    y = M(2); 
    dMdx(1) = sqrt(-2*z - 3*y + sin(x)); 
    dMdx(2) = z; 
end 

그런 다음이 함수를 호출 할 수 있습니다 :

M0 = [ 0 1 ]; % Initial values of ODE 
tfinal = 12;  % Final integration time 
[x,M] = ode45(@odefunc,[0 tfinal],M0) % Integration using the RK-45 algorithm 
관련 문제