Question: 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
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
