Using ODE45 to solve a state space system.
이전 댓글 표시
Hello there!
I stucked in how to use ode45. My problem is the following:
I have a ODE that i want to solve, the only difference is that my initial conditions are vector 3x1.
*function xdot = double_int2(t, y)
xd1 = y(2,:) % xdot = v
xd2 = temp2 + Td % temp2 and Td are vector 1x3
end*
and the other function
*
function [T,Y] = call_double_int2()
x01 = [10 0 0 ];
v01 = [1 0 0];
t_span = [0 5];
[T,Y]= ode45(@double_int2, t_span, [x01 v01])
end*
So, I don't know how to implent in wat that MatLab understand it`s a row vector, I tried to declare the funcion as double_int2(t,y(2,3)), but it always take it as a element.
댓글 수: 4
Francisco
2014년 7월 17일
Sara
2014년 7월 17일
From your description, you don't have four ode's but 12 (3 components * 4 variables), which is totally doable in matlab. Let's take the system you have posted originally for simplicity. It will have to be:
x = y(1:3); %not used but added for clarity
v = y(4:6);
xd1 = v;
xd2 = temp2 + Td;
xdot = [xd1,xd2];
since your v is in y(4:6). Is this clearer? If you can't still do it, post ALL the inputs plus whatever code you have.
Francisco
2014년 7월 23일
Francisco
2014년 7월 23일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!