chp6ex6.m

来自「solve power flows by gauss seidel method」· M 代码 · 共 17 行

M
17
字号
Dx=[10; 10; 10];        % Change in variable is set to a high value
x=[1; 1; 1];                                     % Initial estimate
C=[11; 3; 6];
iter = 0;                                       % Iteration counter
while max(abs(Dx))>=.0001 & iter<10;         % Test for convergence
iter = iter + 1                                 % No. of iterations
F = [x(1)^2-x(2)^2+x(3)^2                               % Functions
     x(1)*x(2)+x(2)^2-3*x(3)
     x(1)-x(1)*x(3)+x(2)*x(3)];
DC =C - F                                               % Residuals
J = [2*x(1)  -2*x(2)      2*x(3)                  % Jacobian matrix
     x(2)    x(1)+2*x(2)  -3
     1-x(3)  x(3)         -x(1)+x(2)]
Dx=J\DC                                         %Change in variable
x=x+Dx                                        % Successive solution
end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?