Euler's Method check
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello, I am trying to model a first order ODE using Euler's Method. I have shown the Euler's step in the code below and I wanted somebody to double-check it and see if it is written correctly. All the R,C,L, Ron values are given. Thankx for the help
h = 0.0001; % Adjustable time-step
t = 0:h:0.002;
for i = 1:length(t)-1
switch (switch_state)
case 1
k11 = x2(i)*1/L - x1(i)*1/(R*C);
k12 = x2(i)*-Ron/L - x1(i)*1/L + Vi*1/L;
otherwise
k11 = x2(i)*1/L - x1(i)*1/(R*C);
k12 = x2(i)*-Ron/L - x1(i)*1/L;
end
x1(i+1) = x1(i) + h*k11;
x2(i+1) = x2(i) + h*k12;
end
plot(t,x1)
plot(t,x2)
0 Kommentare
Akzeptierte Antwort
Iain
am 3 Jun. 2013
You've implemented euler's method correctly. Whether or not you have calculated k11 and k12 correctly, and chosen sensible values for h, and LCR is another question.
4 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Language Fundamentals finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!