fsolve in backward euler method
조회 수: 5 (최근 30일)
이전 댓글 표시
Please help to implement fsolve for a third order ODE
%%
clear
close all
clc
%%
%% The differential equation is : x''' = 2 x'' + 6x
%Boundary condition
%x(0) =1, x'(0) = 0, x''(0)=1,
% Changing a third order differential equation into a system of linear
% equation
%x(1) = x ;
%%x(2) = x' = x(1)'
%x(3) = x'' = x(2)'
%x(3)' = 2 x(3) + 6 x(1)
t0 = 0; %initial value
x0 = [1;0;1]; %initial condition(given)
tEnd = 5; %end of time step
h = 0.001; %step size
N = (tEnd-t0)/h; %number of interval
T = t0:h:tEnd;
X = zeros(3, N+1); %a series of 3-element column vectors
X(:,1) = x0;
for i = 1:N
%fi = [X(2,i);X(3,i);2*X(3,i)+6*X(1,i)];
x = fsolve(@(x) x-X(:,i) - h* %%%%%%%%%); <-- problem.
X(:, i+1) = x;
end
%%
%ploting===================================================================
plot(T,X,'.','LineWidth',2);
title('Approximate solution Euler Implicit Method')
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!