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, 21.06.2019 21:30
Asuccessful format string attack attempted to steal user account information by reading from unauthorized memory. answer the followings with proper explanation a)this attack will lead to violation of which security policies?
Answers: 2
question
Computers and Technology, 22.06.2019 06:50
Match the personality traits with their description
Answers: 1
question
Computers and Technology, 23.06.2019 00:00
Suppose you have 9 coins and one of them is heavier than others. other 8 coins weight equally. you are also given a balance. develop and algorithm to determine the heavy coin using only two measurements with the of the balance. clearly write your algorithm in the form of a pseudocode using the similar notation that we have used in the class to represent sorting algorithms
Answers: 1
question
Computers and Technology, 24.06.2019 01:30
Suppose a cpu with a write-through, write-allocate cache achieves a cpi of 2. what are the read and write bandwidths (measured by bytes per cycle) between ram and the cache? (assume each miss generates a request for one block.)
Answers: 1
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
Mathematics, 30.01.2022 22:40
question
English, 30.01.2022 22:40
question
Biology, 30.01.2022 22:40
Questions on the website: 13722363