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:20
Suppose there is a relation r(a, b, c) with a b+-tree index with search keys (a, b).1. what is the worst-case cost of finding records satisfying 10 < a < 50 using this index, in terms of the number of records n1, retrieved and the height h of the tree? 2. what is the worst-case cost of finding records satisfying 10 < a < 50 and 5 < b < 10 using this index, in terms of the number of records n2 that satisfy this selection, as well as n1 and h defined above? 3. under what conditions on n1 and n2, would the index be an efficient way of finding records satisfying the condition from part (2)?
Answers: 1
question
Computers and Technology, 23.06.2019 16:00
What is the biggest difference between section breaks and regular page breaks? section breaks are more difficult to add than page breaks. section breaks make it easier for you to view the document as an outline. section breaks allow you to have areas of the document with different formatting. section breaks are smaller than regular page breaks.
Answers: 2
question
Computers and Technology, 24.06.2019 11:00
Which of the statements below describe the guidelines for the use of text in presentation programs? a. do not use numbered lists. b. fonts should be appropriate for your audience. c. limit the number of fonts you use to three or four. d. only use bulleted lists for sales promotions. e. select font sizes that are appropriate for your delivery method. f. use font colors that work well with your background. select all that apply
Answers: 1
question
Computers and Technology, 24.06.2019 13:00
Think of a spreadsheet as a giant calculator spread of paper chart data collector
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
Questions on the website: 13722359