Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Create a function to generate and plot the Sierpinski's triangle with side length 1 and user - defined iteration numbers. Define your function output and
Create a function to generate and plot the Sierpinski's triangle with side length and userdefined iteration numbers. Define your function output and name as
sierpinski
where is the number of iterations. are the output of your function, which are the and coordinates of the scattered points forming the triangular shapes.
In your function, first, create and zeros vectors of the length
Second, use forloop to iterate from to and generate a random number from and assign it to variable at the beginning of each step.
Third, in each step, implement the switchcase statements. Use the variable as the switch expression, and use integer and as case expressions.
case ;
case ;
case ;
Last but not least, plot your and y vectors to obtain the Sierpinski's triangle similar to the following illustration.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored 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