Function of ODE can not be executed well.

When I call and execute this function,I get an error.
function dy = myODE(~,y)
dy(1) = y(2);
dy(2) = y(1)*y(2)-2;
end
%code start
[t,y] = ode23(@vdp1,[0 20],[2; 0]);
%code end

답변 (1개)

James Tursa
James Tursa 2017년 6월 26일

0 개 추천

Make sure the derivative function returns a column vector. E.g.,
function dy = myODE(~,y)
dy = zeros(2,1); % <-- column vector
dy(1) = y(2);
dy(2) = y(1)*y(2)-2;
end

이 질문은 마감되었습니다.

태그

질문:

2017년 6월 26일

마감:

2021년 8월 20일

Community Treasure Hunt

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

Start Hunting!