% Parameters
max_iter = 100; % Maximum number of iterations
x_min = -2;     % Minimum x value
x_max = 2;      % Maximum x value
y_min = -2;     % Minimum y value
y_max = 2;      % Maximum y value
width = 800;    % Width of the image
height = 800;   % Height of the image

% Create a grid of complex numbers
x = linspace(x_min, x_max, width);
y = linspace(y_min, y_max, height);
[X, Y] = meshgrid(x, y);
C = X + 1i * Y; % Complex plane

% Define the constant c for the Julia set
c = -0.7 + 0.27015i; % Change this value to explore different Julia sets

% Initialize the output matrix
Z = C; % Start with the grid of complex numbers
output = zeros(size(Z));

% Julia set iteration
for n = 1:max_iter
    mask = abs(Z) <= 2; % Mask for points within the radius
    output(mask) = output(mask) + 1; % Increment the count
    Z(mask) = Z(mask).^2 + c; % Update Z with the constant c
end

% Display the Julia set
imagesc(x, y, output);
colormap(hot); % Change colormap
axis xy; % Correct the axis orientation
colorbar; % Show color scale
title('Julia Set for c = -0.7 + 0.27015i');
xlabel('Re(z)');
ylabel('Im(z)');