chp6ex3.m

来自「Those who are working on power system op」· M 代码 · 共 13 行

M
13
字号
chp6fig4                        % Graphical display for Example 6.3
dx=1;                   % Change in variable is set to a high value
x=2;                                             % Initial estimate
iter = 0;                                       % Iteration counter
disp('Iter    g         dx        x')         % Heading for results
while abs(dx) >= 0.001 & iter < 100          % Test for convergence
iter = iter + 1;                                % No. of iterations
g = -1/9*x^3+6/9*x^2+4/9;
dx = g-x;                                      % Change in variable
x = x + 1.25*dx; % Successive approximation with 1.25 accel. factor
fprintf('%g', iter), disp([g, dx, x])
end

⌨️ 快捷键说明

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