Solving second order differential equation using euler forward algorithm

1 次查看(过去 30 天)
i need to solve a second order differential equation with writing loop by using euler forward algorithm.i listed my parameter as follows L=62.5e-3; R=200e-3; C=6.25e-6; V_s=60; initial condition : x1(0)=0; x2(0)=0;
now i define my equation as follows x1'=x2; x2'=(1/LC)*V_s-(R/L)*x2- (1/LC) x1; output: y=x1 In the following part i have to program the Euler's method to solve this problem and plot with respect to time and output y. defined some parameter for euler algorithm:
Tsim = 5; % simulate over Tsim seconds h = 0.01; % step size N= Tsim/h; % number of steps to simulation x(1)= 0 ; x(2)= 0; Simulation loop using Euler method for k=1:N How can i apply loop and get the plot from this ?
Input: model function x' = f(x) , simulation step size h, number of steps N to simulate, initial state x(1) Algorithm: for k from 1 to N, x(k+1) = x(k) + h*f(x(k)) end Output: sequence of simulated states x(1), x(2), …, x(N+1). output,y=x1
kindly can anybody help me ?i am new here.
  1 个评论
John D'Errico
John D'Errico 2016-6-28
It would help if you posted code that was actually readable.
Learn to use the "{} Code" button. Select a block of code when you paste it in. Then click on the "{} Code" button to format it as such.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Mathematics 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by