Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A fractal is a curve or geometric figure, each part of which has the same statis

ID: 2073817 • Letter: A

Question

A fractal is a curve or geometric figure, each part of which has the same statistical character as the whole. Fractals are useful in modeling structures (such as eroded coastlines or snowflakes) in which similar patterns recur at progressively smaller scales and in describing partly random or chaotic phenomena such as crystal growth, fluid turbulence, and galaxy formation. Devaney (1990) has written a nice little book that includes a simple algorithm to create an interesting fractal pattern. Here is a step-by-step description of this algorithm:

Step 1: Assign value to m and n and set hold on.
Step 2: Start a for loop to iterate over i = 1:100000
Step 3: Compute a random number, q = 3*rand(1)
Step 4: If the value of q is less than 1 go to Step 5. Otherwise go to Step 6.
Step 5: Compute new values for m = m/2 and n = n/2 and then go to Step 9.
Step 6: If the value of q is less than 2 go to Step 7. Otherwise go to Step 8.
Step 7: Compute new values for m = m/2 and n = (300 + n)/2, and then go to Step 9.
Step 8: Compute new values for m = (300 + m)/2 and n = (300 + n)/2.
Step 9: If i is less than 100000 then go to Step 10. Otherwise, go to Step 11.
Step 10: Plot a point at the coordinate (m,n).
Step 11: Terminate i loop.
Step 12: Set hold off.

Develop a MATLAB script for the given algorithm using for and if structures, and run it for the case m = 100 and n = 200.

Explanation / Answer

Matlab code:

% Step 1
m = 100;
n = 200;
hold on
% Step 2
for i = 1:100000
    q = 3*rand(1); % Step 3
    if q < 1 % Step 4
        % Step 5
        m = m/2;
        n = n/2;
    elseif q < 2 % Step 6
        % Step 7
        m = m/2;
        n = (300+n)/2;
    else
        % Step 8
        m = (300+m)/2;
        n = (300+n)/2;
    end
  
    plot(m,n,'.b') % Step 9 & 10
  
end % Step 11
hold off % Step 12
   

   

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote