Solving second order differential equation using euler forward algorithm
Show older comments
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 Comment
John D'Errico
on 28 Jun 2016
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.
Answers (0)
Categories
Find more on Mathematics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!