•Download as DOCX, PDF•

0 likes•4 views

2) A fractal is a curve or geometric figure comprised of a pattern that repeats at every scale. One approach to generating a fractal is called a chaos game. A chaos game is an algorithm in which points are plotted iteratively according to small set of rules. After a sufficient number of points are plotted, a pattern emerges. A section of the boundary of the Dragon Curve fractal can be plotted in MATLAB using the chaos game approach by plotting points iteratively according to one of the following three rules that are selected randomly with equal probability. (You will need to look up the randi function.) Write a MATLAB script that calculates the x and y vectors, then plots x vs y using plot(x,y,\'.r\'). Start with x1 = 0 and y1 = 1. Perform 50000 iterations. Hint 1: At each iteration you\'ll calculate a new x and y from the old x and y. Which rule you use to calculate the new x and y is determined by \'\'flipping a coin\'\' (randi). This coin flip happens every iteration. Solution Matlab Code: x(1)=0; y(1)=1; % Initially setting x=0;y=1 for i=1:50000 % looping from 1 to 50000 p=randi(3); % Generating a random number 1,2 or 3 will be generated if p==1 % Initially i=1 will be selected and it will check whether randi() generated 1,2 or 3. x(i+1)=((x(i)-y(i))/4)-(1/2); % if randi(3) generated 1 it will come to this line y(i+1)=((x(i)+y(i))/4)+1; else if p==2 % if randi(3) generated 2 it will execute this loop x(i+1)=((y(i)-x(i))/4)+(1/2); y(i+1)=-((x(i)+y(i))/4)+1; else if p==3 % if randi(3) generated 3 it will execute this loop and will generate x,y from previous values x(i+1)=((x(i)+y(i))/2)+1; y(i+1)=((y(i)-x(i))/2); end end end end % In this way we get a vector of x,y values and now we plot them plot(x,y,\'.r\') .

Report

Share

Report

Share

Research Inventy : International Journal of Engineering and Science

Research Inventy : International Journal of Engineering and Science

Chi-squared Goodness of Fit Test Project Overview and.docx

Chi-squared Goodness of Fit Test Project Overview and.docx

INTRODUCTION TO MATLAB presentation.pptx

INTRODUCTION TO MATLAB presentation.pptx

A25-7 Quadratic Inequalities

A25-7 Quadratic Inequalities

Rasterization.pptx

Rasterization.pptx

Numerical Methods and Applied Statistics Paper (RTU VI Semester)

Numerical Methods and Applied Statistics Paper (RTU VI Semester)

Lec3

Lec3

The world of loss function

The world of loss function

Matlab cheatsheet

Matlab cheatsheet

Final exam mariluz 1

Final exam mariluz 1

5.2 using intercepts

5.2 using intercepts

5.2 using intercepts

5.2 using intercepts

Commands list

Commands list

Matlab tutorial 2

Matlab tutorial 2

Vertical asymptotes to rational functions

Vertical asymptotes to rational functions

Rational Functions

Rational Functions

Ses 3 quadratic equations

Ses 3 quadratic equations

Lesson 8

Lesson 8

COMPANION TO MATRICES SESSION II.pptx

COMPANION TO MATRICES SESSION II.pptx

Regression

Regression

1Experimental Chemistry Data Analysis 1- How do you know when to name.docx

1Experimental Chemistry Data Analysis 1- How do you know when to name.docx

18) Explain why oil and water do not mix- A) Water is not able to ioni.docx

18) Explain why oil and water do not mix- A) Water is not able to ioni.docx

17-Calcium sulfate has a soluble form in water- formed according to-.docx

17-Calcium sulfate has a soluble form in water- formed according to-.docx

2- Does evolution violate the second law of thermodynamics- Why or why.docx

2- Does evolution violate the second law of thermodynamics- Why or why.docx

2- Discuss the advantages and disadvantages of using the following com.docx

2- Discuss the advantages and disadvantages of using the following com.docx

2- Create a multi - step Income Statement- Statement of Retained Earni.docx

2- Create a multi - step Income Statement- Statement of Retained Earni.docx

2- Compare teh payment of cash divididends- stock dividends and purcha.docx

2- Compare teh payment of cash divididends- stock dividends and purcha.docx

31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...

31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...Nguyen Thanh Tu Collection

Concurrency Control in Database Management system

Concurrency Control in Database Management system

Scientific Writing :Research Discourse

Scientific Writing :Research Discourse

Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx

Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx

DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx

DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx

Reading and Writing Skills 11 quarter 4 melc 1

Reading and Writing Skills 11 quarter 4 melc 1

Multi Domain Alias In the Odoo 17 ERP Module

Multi Domain Alias In the Odoo 17 ERP Module

Active Learning Strategies (in short ALS).pdf

Active Learning Strategies (in short ALS).pdf

Q-Factor General Quiz-7th April 2024, Quiz Club NITW

Q-Factor General Quiz-7th April 2024, Quiz Club NITW

INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx

INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx

INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx

INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx

Daily Lesson Plan in Mathematics Quarter 4

Daily Lesson Plan in Mathematics Quarter 4

Narcotic and Non Narcotic Analgesic..pdf

Narcotic and Non Narcotic Analgesic..pdf

Transaction Management in Database Management System

Transaction Management in Database Management System

Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...

Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...

31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...

31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...

Mythology Quiz-4th April 2024, Quiz Club NITW

Mythology Quiz-4th April 2024, Quiz Club NITW

Using Grammatical Signals Suitable to Patterns of Idea Development

Using Grammatical Signals Suitable to Patterns of Idea Development

4.11.24 Poverty and Inequality in America.pptx

4.11.24 Poverty and Inequality in America.pptx

ClimART Action | eTwinning Project

ClimART Action | eTwinning Project

4.16.24 Poverty and Precarity--Desmond.pptx

4.16.24 Poverty and Precarity--Desmond.pptx

- 1. 2) A fractal is a curve or geometric figure comprised of a pattern that repeats at every scale. One approach to generating a fractal is called a chaos game. A chaos game is an algorithm in which points are plotted iteratively according to small set of rules. After a sufficient number of points are plotted, a pattern emerges. A section of the boundary of the Dragon Curve fractal can be plotted in MATLAB using the chaos game approach by plotting points iteratively according to one of the following three rules that are selected randomly with equal probability. (You will need to look up the randi function.) Write a MATLAB script that calculates the x and y vectors, then plots x vs y using plot(x,y,'.r'). Start with x1 = 0 and y1 = 1. Perform 50000 iterations. Hint 1: At each iteration you'll calculate a new x and y from the old x and y. Which rule you use to calculate the new x and y is determined by ''flipping a coin'' (randi). This coin flip happens every iteration. Solution Matlab Code: x(1)=0; y(1)=1; % Initially setting x=0;y=1 for i=1:50000 % looping from 1 to 50000 p=randi(3); % Generating a random number 1,2 or 3 will be generated if p==1 % Initially i=1 will be selected and it will check whether randi() generated 1,2 or 3. x(i+1)=((x(i)-y(i))/4)-(1/2); % if randi(3) generated 1 it will come to this line y(i+1)=((x(i)+y(i))/4)+1; else if p==2 % if randi(3) generated 2 it will execute this loop x(i+1)=((y(i)-x(i))/4)+(1/2); y(i+1)=-((x(i)+y(i))/4)+1; else if p==3 % if randi(3) generated 3 it will execute this loop and will generate x,y from previous values x(i+1)=((x(i)+y(i))/2)+1; y(i+1)=((y(i)-x(i))/2); end end end end % In this way we get a vector of x,y values and now we plot them plot(x,y,'.r')