필터 지우기
필터 지우기

ode numerical answer with euler-method

조회 수: 4 (최근 30일)
tomer polsky
tomer polsky 2018년 1월 3일
편집: James Tursa 2018년 1월 3일
hello i am trying to solve ode with Euler’s Method this state equtin x_dot=A*x+B*U
when x_dot=2x1,A=2x2,x=2x1,b=2x1,U=1x1 .
i dit it for one varbile but how do i do it when i have 2 varbles (meaning that i habe 2 solutions for x and not 1 sulotion for x )

답변 (1개)

James Tursa
James Tursa 2018년 1월 3일
편집: James Tursa 2018년 1월 3일
You do it for vectors pretty much the same way you would do it for scalars. The main difference would be that you need to account for the fact that x is a vector if you are saving all of the intermediate results. E.g., something like this:
% set constants etc here
x = some initial value
t = some initial value
dt = some step size
n = number of steps to take
xresult = zeros(numel(x),n); % allocate the result variable
xresult(:,1) = x; % save initial value
for k=2:n
% if needed, update A, B, U here
x_dot = A*x + B*U; % calculate derivative
x = x + x_dot*dt; % take the Euler step
t = t + dt;
xresult(:,k) = x; % save this intermediate result
end

카테고리

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