Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The triangle shown in Figure 1 is a fractal, an infinitely repeating pattern, known as Serpinski's triangle. This pattern can be created mathematically by repeating
The triangle shown in Figure 1 is a fractal, an infinitely repeating pattern, known as Serpinski's triangle. This pattern can be created mathematically by repeating the following steps Figure 1 Choose three points to be the corners of the triangle. You may choose Point 1-(0 0), Point 2 (0, 10), and Point 3- (5, 10) to make a symmetric triangle with the same height and base. Plot points on a figure Prompt the user for a starting point x-value and y-xalue) and the number of iterations to perform. Use the randi function to randomly choose a corner point (Point 1, 2, or 3). This may be done by typing randi (3) which will randomly choose a value between 1 and 3. A value of 1 corresponds to Point 1, value of 2 corresponds to Point 2, etc. Calculate the midpoint between the randomly chosen corner point and the starting point. Plot midpoint on the same figure. Make your midpoint your new starting point. Repeat steps 4 through 7 for the desired number of iterations. 1. 2. 3. 4. 5. 6. 7. 8. Write a script file that implements this algorithm for 100, 1000, and 10000 iterations. Your midpoint calculation must be performed in a function named CalculateMidpoint which requires 2 inputs: the first point and the second point, and returns/outputs the midpoint between the two points. Ensure your function is properly commented to include an H1 and help text lines. You may use the pause (0.1) function after step 6 to see the graph fill up with points. Your three corner points must be plotted as magenta circles and your starting point must be a green star. All other points must be black
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started