跳至内容

电路理论/1 源激发/示例 7/代码

摘自维基文库,开放世界的开放书籍

在 Matlab 中

R = 10;
L = .01;
w = 377;
Vm = 120*2^.5;
omega = 2*pi/3;
Im = Vm/(R^2+(L*w)^2)^.5;
alpha = omega - atan(L*w/R);
syms t A C;
I = Im * cos(w*t+alpha) + A*exp(-t/(L/R)) + C;
leftSide = Vm*cos(w*t + omega) - I*R;
rightSide = L * diff(I,t);
vpa(leftSide, 3);
vpa(rightSide,3);
t=0;
teq = subs(leftSide) - subs(rightSide)
vpa(teq,3)
Ieval = subs(I);
vpa(Ieval,3)
S = solve(Ieval,teq,A,C);
S = [S.A S.C];
vpa(S(1),3)
vpa(S(2),3)

在 MuPad 和 MatLab 中(必须剪切并粘贴)

R := 10;
L := .01;
w := 377;
Vm := 120*2^.5;
omega := 2*pi/3;
Imagnitude := Vm/(R^2+(L*w)^2)^.5;
alpha := omega - atan(L*w/R);
Itime := Imagnitude * cos(w*t+alpha) + A*exp(-t/(L/R)) + C;
dItime := diff(Itime,t);
t:=0;
numeric::solve([Itime=0,Vm*cos(w*t + omega) - Itime*R -  L * dItime = 0],[A,C],FixedPrecision)

sig1 = 5.986596875*sin(2*pi/3 - atan(0.377));
sig2 = cos(2*pi/3 - atan(0.377));
A = -16.97056275*cos(2*pi/3) - 2.775557562*10^-17*sig2 - sig1
C =   16.97056275*cos(2*pi/3) - 15.87956731*sig2+ sig1

华夏公益教科书