Borrar filtros
Borrar filtros

modeling a forest fire

7 visualizaciones (últimos 30 días)
John Jamison
John Jamison el 26 de Mzo. de 2017
Comentada: John Jamison el 28 de Mzo. de 2017
We are tasked with the question seen attached below, simulating a forest fire.
I have the following code, but was looking for some ideas or help on finishing off this problem.
Thanks
function outcomes = fire(numRows, numCols, startRow, startCol, trials)
% Simulate the spread of a fire.
start = (startRow, startCol)
if nargin == 5
trials = trials; % #trials = number of trials user inputs
elseif nargin == 4
trials = 1; %if not specified, trials = 1
%if only one trials performed, display the fire simulation
end
while (startRow > 0 && startCol > 0 && numRows > 0 && numCols > 0) %runs the function while in the boundaries specified (ie. doesnt reach bottom end of grid)
currLoc = start + 1 %current location = starting location + 1
for i = 1 : trials %duration of simulation
[a b] = fire(outcomes, trials);
if a == 1
outcomes = outcomes + 1;
end
end
end
if currLoc == 0 %fire went out
success = 0;
else %fire continues
success = 1;
end
colormap([.035 .200 .153; 1.00 .367 .063; .561 .510 .592]) % rgb values for green, orange, gray
map = [ 1 1 1 1; 3 3 3 1; 2 3 3 1 ];
image(outcomes);
end

Respuestas (1)

Star Strider
Star Strider el 26 de Mzo. de 2017
I saw this once before and thought it interesting enough to save the URL in my archive.
  3 comentarios
Star Strider
Star Strider el 26 de Mzo. de 2017
I’ll defer to you for that.
I archived it because it was one of the neatest simulations I’ve seen!
John Jamison
John Jamison el 28 de Mzo. de 2017
any tips for getting it to work with trials? How can I get it to write the outcomes?

Iniciar sesión para comentar.

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by