apparently I was skipped by accident

13.2 A quadratic Julia set has the form

z(n+1)=z(n)^2+c

The special case where c=-.123+.745i is called Douday's rabbit fractal. Follow example 13.1, and create an image using this value of c. For the Madelbrot image, we started with all z-values equal to 0. You'll need to start with z=x+yi. Let both x and y vary from -1.5 to 1.5.

I'm really confused by this question. Here's my attempt at a solution. I really hope someone can help me. My book did a very bad explaining the matter.

Code:
>> iterations=80;
grid_size=500;
[x,y]=meshgrid(linspace(-1.5,1.5,grid_size),linspace(-1.5,1.5,grid_size));
c=-.123+.745*i;
z=x+y*i;
map=x+y*i;
for k=1:iterations
z=z.^2+c;
a=find(abs(z)>sqrt(5));
map(a)=k;
end
figure(1)
image(map)
colormap(jet)
??? Error using ==> image
Error using ==> image
Image CData can not be complex

We have only one or two tutors who can help with programming, and they don't get online every day. Please be patient.

It looks to me that your code follows the logic correctly.

There is a minor error which caused the error message, namely you have defined the map matrix to be complex. When it comes to plot, it causes difficulties.

On line 6, try setting all values to zero
map=zeros(grid_size, grid_size)
which will be replaced by the (max) number iterations during the iterations.

Using a grid of 51 (instead of 500), it gives me a pattern not dissimilar to what's expected. I am not able to test the plotting part.

Try and post to let us know if it works or not.

The error message "Image CData can not be complex" indicates that the `image` function cannot handle complex numbers. To create the Julia set image with complex numbers, you can use the `imshow` function instead of `image`. Here's an updated version of the code:

```MATLAB
iterations = 80;
grid_size = 500;

[x, y] = meshgrid(linspace(-1.5, 1.5, grid_size), linspace(-1.5, 1.5, grid_size));

c = -.123 + .745i;
z = x + y * 1i;
map = x + y * 1i;

for k = 1:iterations
z = z.^2 + c;
a = find(abs(z) > sqrt(5));
map(a) = k;
end

figure(1)
imshow(map, 'DisplayRange', [1, iterations])
colormap(jet)
```

With these changes, the complex values of `map` are visualized using `imshow`, and the resulting image will be displayed with a colormap.

The error message you received indicates that there is an issue with the complex values in your code. The `image` function in MATLAB does not support complex data as input.

To resolve this issue, you need to modify the code so that it works with real values. One common approach is to keep track of the magnitude of `z` instead of using the complex number directly.

Here's an updated version of your code:

```matlab
iterations = 80;
grid_size = 500;
[x, y] = meshgrid(linspace(-1.5, 1.5, grid_size), linspace(-1.5, 1.5, grid_size));
c = -.123 + .745i;
z = x + y * 1i;
map = zeros(size(z));
for k = 1:iterations
z = z.^2 + c;
a = abs(z) > sqrt(5);
map(a) = k;
end
figure(1)
image(map)
colormap(jet)
```

In this code, we initialize `map` as a matrix of zeros with the same size as `z`. Instead of assigning complex values to `map`, we assign the iteration count `k` whenever the magnitude of `z` exceeds the threshold, `sqrt(5)`.

Now, when you run this code, it should generate the desired image using the value of `c` specified.