Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MATLAB HELP!!!! Write a script called lastnameConway.m with the following elements: 1. Use the readpattern() function (provided below) to read any one of five pattern

MATLAB HELP!!!!

Write a script called lastnameConway.m with the following elements:

1. Use the readpattern() function (provided below) to read any one of five pattern files (also provided below) as a variable called P.

2. Determine the width (W) and height (H) of P.

3. Create board (B) of all zeros whose width is 4*W and height is 4*H.

4. Place the pattern P near the center of board B.

5. Apply the rules of Conway's Game of Life using the functions and procedures we described in lecture to animate 100 generations with a delay of 0.25 s between animation updates.

Code for readpattern:

function P = readpattern(filename) % Example usage: % % P = readpattern('galaxy.txt'); % % S = readlines(filename); nRow = length(S); nCol = strlength(S(1)); P = zeros(nRow, nCol); for i = 1:nRow thisRow = char(S(i)); for j = 1:nCol thisChar = thisRow(j); if strcmp(thisChar, 'O') P(i,j) = 1; end end end 

Pattern File:

..O..O.O. OO.O.OOO. .O......O OO.....O. ......... .O.....OO O......O. .OOO.O.OO .O.O..O..

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Heat And Mass Transfer Fundamentals And Applications

Authors: Yunus Cengel, Afshin Ghajar

5th Edition

0073398187, 978-0073398181

More Books

Students also viewed these Chemical Engineering questions

Question

1.who the father of Ayurveda? 2. Who the father of taxonomy?

Answered: 1 week ago

Question

Commen Name with scientific name Tiger - Wolf- Lion- Cat- Dog-

Answered: 1 week ago