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, 22.06.2019 17:00
The two main ways in which marketers address the competition with their strategies are by satisfying a need better than a competition and by
Answers: 2
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, 24.06.2019 04:30
What is the process in which the software development team compiles information to determine the final product
Answers: 1
question
Computers and Technology, 24.06.2019 23:00
People should never use telepresence when virtually meeting with a group of co-workers. true false
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
Physics, 20.12.2020 03:10
question
Physics, 20.12.2020 03:10
question
Mathematics, 20.12.2020 03:10
Questions on the website: 13722363