subject

Step 1 : grab the file Execute your script after adding a proper load() call then check your workspace. The code should run without any output, and within your workspace you can now see all the variables stored in the .mat file.
step 2 : display the initial grid
In this step we want to call the provided function displayGrid() for the first time. The function takes a single input, a grid, so we send the current grid as the only function argument. After our function call we should pause for 2 seconds, allowing the figure and other graphics to load prior to any future animation.
step 3: the percolate function
The goal of the percolate function is to move water from any spot in the grid that currently contains water to a set of its neighbors. The function performs a single iteration of percolation across the entire grid. The function name is percolate and it has a single input and a single output. The input is the 2D array (the grid) in its current state. The single output is a 2D array containing the new grid after a single iteration of percolation has occurred. This output/return value should be assigned into the grid in the main scripting area when the function is called to overwrite the current grid, thus completing the update.
step 4 : Call the percolate Function & Display Updated Grid
Once the percolate function is completed in part or in totality, you will need to call it within the main scripting area to execute the function and acquire the return value to update the grid variable. The provided displayGrid() function can be used to help visually evaluate the percolate function's functionality.
displayGrid() should be called in your main scripting area (completed in Step 2) before the percolate function is called and then again after the percolate function returns and updates the grid variable.
After this second call, pause just like after the first, but this time for 0.1 seconds.
At this point you should be able to reproduce the initial, 1st, and 2nd grids in the above table by calling percolation twice and displaying the grid in a new figure each time. Alternatively if you pause and use a single figure then you will see a short 3 step animation sequence.
step 5 : add the amination loop
The final coding step is to encompass your percolate(), displayGrid(), and pause() calls into an animation loop. This loop should continue going as long as the endPoint is not in the WATER state (it's value is not equal to the value of WATER). The endPoint variable was discussed in Step 1.
starter code :
close all;
clear;
% TODO: Step 1
% TODO: Define these states in every function you write.
% Then use the names instead of the numeric literal values.
% Three potential states of the grid
WATER = 1;
IMPERMEABLE = 0;
PERMEABLE = 2;
% TODO: Complete Step 2
% TODO: Complete step 4 and then once complete, complete step 5.
% TODO: Complete Step 3
function displayGrid(grid)
% Displays the provided 2D array using a specific colormap
% INPUTS: grid - the 2D array representating the current percolation state
% OUTPUTS: displays the 2D array using imagesc
colormap colorcube;
imagesc(grid)
axis off;
end
can test with the following code :
function importfile(fileToRead1)
%IMPORTFILE(FILETOREAD1)
% Imports data from the specified file
% FILETOREAD1: file to read
% Import the file
newData1 = load('-mat', fileToRead1);
% Create new variables in the base workspace from those fields.
vars = fieldnames(newData1);
for i = 1:length(vars)
assignin('base', vars{i}, newData1.(vars{i}));
end

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 10:30
How would you categorize the software that runs on mobile devices? break down these apps into at least three basic categories and give an example of each.
Answers: 1
question
Computers and Technology, 23.06.2019 14:00
Technician a says that with self-adjusting clutch systems, the release bearing constantly rotates. technician b says that the ball bearing portion of the release bearing should be lubricated with high-temperature grease during routine maintenance. which technician is correct?
Answers: 2
question
Computers and Technology, 23.06.2019 18:00
What can a word user do with the customize ribbon dialog box? check all that apply. minimize the ribbon add a new tab to the ribbon remove a group from a tab add a group to a tab choose which styles appear choose which fonts appear choose tools to appear in a group
Answers: 1
question
Computers and Technology, 23.06.2019 21:10
Asample of 200 rom computer chips was selected on each of 30 consecutive days, and the number of nonconforming chips on each day was as follows: 8, 19, 27, 17, 38, 18, 4, 27, 9, 22, 30, 17, 14, 23, 15, 14, 12, 20, 13, 18, 14, 20, 9, 27, 30, 13, 10, 19, 12, 26. construct a p chart and examine it for any out-of-control points. (round your answers to four decimal places.)
Answers: 2
You know the right answer?
Step 1 : grab the file Execute your script after adding a proper load() call then check your works...
Questions
question
English, 09.12.2020 03:00
question
Mathematics, 09.12.2020 03:00
question
Geography, 09.12.2020 03:00
Questions on the website: 13722361