How can I introduce dead trees into a model of a forest fire?

5 views (last 30 days)
I am trying to model a forest fire and have got the following code so far:
n = 50;
X = zeros(n,n);
X(n/2,n/2) = 1;
p = [n 1:n-1];
q = [2:n 1];
r = [1:5];
Pr = 1; %propability of fire spreading to neighbouring trees
Z=zeros(n,n);
for t = 1:30
Y = rand(n,n);
X = ((X(:,p) | X(:,q) | X(p,:) | X(q,:)) & (Y <= Pr)) | X;
Z=Z+X;
pause(0.5)
pcolor(Z);
colorbar;
title(num2str(t));
drawnow;
end
This doesn't account for dead/burnt trees, I want to set a tree's death to be after 3 generaions of being on fire. I have tried setting Z(Z>3) = 0 but the new 0's become 1's shortly after, which then become 3's eventually then back to 0.
Any help on this matter wil be greatly appreciated!

Accepted Answer

darova
darova on 1 Apr 2019
  2 Comments
Oliver Tremlett
Oliver Tremlett on 5 May 2019
Thank you, would you have any idea how I would change the tree density so that not every cell contatins a tree?
darova
darova on 5 May 2019
Read about how imdilate() works
You can also create whatever you want and place it in matrix with imdilate()

Sign in to comment.

More Answers (0)

Categories

Find more on Applications in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!