Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Chemical Engineering Questions!