i try to solve RLC circuit i got voltage and current in the circuit as a plot i want to calculate power in the circuit usiing simpsons rule
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
function AMfixed4order h = 0.1; T = 1:h:100; YAB = [ 0 0 0 0 0 0 0 0]
YAM = [ 0 0 0 0 0 0 0 0]
YAB(:, 3) = YAB(:, 4) - h*F(T(1)-h, YAB(:, 4)); YAM(:, 3) = YAM(:, 4) - h*F(T(1)-h, YAM(:, 4)); YAB(:, 2) = YAB(:, 3) - h*F(T(1), YAB(:, 3)); YAM(:, 2) = YAM(:, 3) - h*F(T(1), YAM(:, 3)); YAB(:, 1) = YAB(:, 2) - h*F(T(1)-h, YAB(:, 2)); YAM(:, 1) = YAM(:, 2) - h*F(T(1)-h, YAM(:, 2));
for i = 1:length(T)-1
% 4rd order multistep Adams-Bashforth
YAB(:, 4+i) = YAB(:, 3+i) + h*(55/24*F(T(i),YAB(:, 3+i)) - 59/24*F(T(i)-h, YAB(:, 3+i-1)) + 37/24*F(T(i)-2*h, YAB(:, 3+i-2)) - 9/24*F(T(i)-3*h, YAB(:, 3+i-3)));
YAM(:, 4+i) = YAB(:, 4+i) + h*(9/24*F(T(i),YAM(:, i+3)) + 19/24*F(T(i),YAM(:, i+1))- 5/24*F(T(i),YAM(:, i+2)) + 1/24*F(T(i), YAM(:, i+3)));
% YAM(:, 3+i) = YAB(:, 3+i) + h*(5/12*F(T(i), YAM(:, i+2)) + 8/12*F(T(i),YAM(:,i)- 1/12*F(T(i),YAM(:,i+1))))
%YA(:,i+1) =rlc_1(T(i));
end
plot(T, YAM(1,4:end) ,T, YAM(2,4:end))
% A = sum(abs(YAM(1,4:end)- YA(1,:)))*h
%B = sum(abs(YAM(2,4:end)- YA(2,:)))*h
end
function dY = F(t, Y)
L = 2;
C = 0.6;
R = 5;
E = 10;
dY = [1/L *(E-Y(2)) 1/(R*C) * (E - Y(2) + R*Y(1))]; end
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Specialized Power Systems dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!