% chaosp1.m
% 代表的なカオスモデルを描画するプログラム
% 使用例:
% chaosp1(25,10,0.55,0.9,2000,1);
% chaosp1(4,0,0.55,1,2000,3);

function chaosp1(x0, y0, a, b, n, method)
  X = []; Y = [];
  for k = 1:n
    % モデルごとに u を計算
    if method == 1
      u = 4 * atan(x0);
    elseif method == 2
      u = 4 * atan(x0) / (1 + x0^2);
    elseif method == 3
      u = 0.9 * y0 + atan(y0);
    elseif method == 4
      u = -5 * x0^2 / (x0^2 + 1) + 6 + 0.2 * exp(-y0^2);
    else
      disp('error: method must be 1–4');
      break;
    end

    % 反復式
    x = y0 + a * x0 + u;
    y = -b * x0;

    % 座標を保存
    X = [X x];
    Y = [Y y];

    % 次のステップへ
    x0 = x;
    y0 = y;
  end

  % 描画
  plot(X, Y, '.', 'MarkerSize', 1);
  axis square; axis off;
end

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: