Question

4 MARKS QUEStION 3 Background You are part of a team working for the United Nations Environment Programme (UNEP) to investigate the deforestation process in Borneo. You are provided six images of the forest area in Borneo from 1950-2020 which comprise of historical and projection data. Forests are represented as green pixels and deforested areas as yellow pixels. Q3a In the Q3a.m file, use the imread() function to read the images. For each year (1950, 1985, 2000, 2005, 2010, 2020), calculate the percentage forested area (PFA) which is defined as: forest area green pixels PFA 10096-greenandyellow pixe >< 100% green and Write the year, forested area, total land area and PFA to a file named BorneoForestData.txt. The file should look like the following Forest Area T tal Land Area (%) Year 1950 1985 PEA Hint: Green (forest) in grayscale 75 to 115 (inclusive) Light blue (water) in grayscale 240 Black (text) in grayscale 0 All other colours in grayscale represent land You should still have five figure windows by the end of this task. Q3b In the Q3b.m file, plot the PFA against the year as blue circles in a new figure. You believe that the data can be appropriately represented by either an exponential model or a 2nd order polynomial model. Find the coefficients for each model based on the form of the equations below: Exponential model: PFA-aePt 2nd order polynomial model: PFA at2 bt c where a, B, a, b, c are coefficients, and t represents the year Plot both fitted models for years 1950 to 2100 (yearly increments) on the newly created figure. Print the equations of the fitted models to the command window using the exponential specifier for fprintf You should have six figure windows by the end of this task.In the Q3c.m file, perform the Newton-Raphson method on both models described in Q3b to estimate the year when Borneo will have no forests left. Perform the root-finding method using precision values of 1e-1, 1e-2, 1e-3 1e-10, and present the results in a tabular structure in the command window similar to the following. Year Exponential P?? P?? P?? Year Precision 1e-01 1e-02 1e-03 Polynomial P?? Print one sentence that states whether the exponential or polynomial model is more appropriate and provide justification for your choice You should still have six figure windows by the end of this task. You are asked to further investigate the 2nd order polynomial model considering the effect of neglecting the a coefficient. Thus, the two ordinary differential equations that may model the Borneo deforestation data are: Model 1 d(PFA) 2at+ b (quadratic) Model 2 d(PFA) (linear): dt where a and b are the coefficients from the 2nd order polynomial model (see 03b) In the Q3d.m file, solve the annual PFA in Borneo by applying the midpoint method to both models. Use a step size of 0.001 years and the PFA value calculated for 1950 as the initial condition. The range of years should span 1950 to 2100 In a 1x2 subplot figure, plot the following: PFA obtained in Q3a against the year as blue circles. [both panels] PFA values obtained by solving Model 1 as a red line. [left panel] PFA values obtained by solving Model 2 as a black line. [right panel] Remember to include a legend. Use fprintf to provide a one-sentence explanation for why model 2 does not provide an appropriate linear fit of the PFA data You should have seven figure windows by the end of this task. Poor Programming Practices Includes, but is not limited to, poor coding style or insufficient comments or unlabeled figures, etc.) [-2 MarkS]

0 0
Add a comment Improve this question Transcribed image text
Answer #1

%Read the image
I1950 = imread('1950.png');
I1985 = imread('1985.png');
I2000 = imread('2000.png');
I2005 = imread('2005.png');
I2010 = imread('2010.png');
I2020 = imread('2020.png');

%Display the image
subplot(3, 2, 1);
imshow(I1950);
subplot(3, 2, 2);
imshow(I1985);
subplot(3, 2, 3);
imshow(I2000);
subplot(3, 2, 4);
imshow(I2005);
subplot(3, 2, 5);
imshow(I2010);
subplot(3, 2, 6);
imshow(I2020);

%Identify Green and Yellow Pixels for image 1950
countG = 0;
countY = 0;
[x, y, z] = size(I1950);
for i = 1:x
for j = 1:y
for k = 1:z
%Check for Green Pixels
if I1950(i, j, k)>=75 && I1950(i, j, k)<=115
countG = countG+1;
  
%Check for Yellow Pixels
elseif I1950(i, j, k)~=0 && I1950(i, j, k)~=240
countY = countY+1;
end
end
end
end

%Calculate PFA
PFA = countG*100/(countG+countY);

%Write to file
fileID = fopen('BorneoForestData.txt', 'w');
fprintf(fileID, 'Year Forest Area Total Land Area PFA ');
fprintf(fileID, '%d %d %d %f ', 1950, countG, countG+countY, PFA);

%Identify Green and Yellow Pixels for image 1985
countG = 0;
countY = 0;
[x, y, z] = size(I1985);
for i = 1:x
for j = 1:y
for k = 1:z
%Check for Green Pixels
if I1985(i, j, k)>=75 && I1985(i, j, k)<=115
countG = countG+1;
  
%Check for Yellow Pixels
elseif I1985(i, j, k)~=0 && I1985(i, j, k)~=240
countY = countY+1;
end
end
end
end

%Calculate PFA
PFA = countG*100/(countG+countY);

%Write to file
fprintf(fileID, '%d %d %d %f ', 1985, countG, countG+countY, PFA);

%Identify Green and Yellow Pixels for image 2000
countG = 0;
countY = 0;
[x, y, z] = size(I2000);
for i = 1:x
for j = 1:y
for k = 1:z
%Check for Green Pixels
if I2000(i, j, k)>=75 && I2000(i, j, k)<=115
countG = countG+1;
  
%Check for Yellow Pixels
elseif I2000(i, j, k)~=0 && I2000(i, j, k)~=240
countY = countY+1;
end
end
end
end

%Calculate PFA
PFA = countG*100/(countG+countY);

%Write to file
fprintf(fileID, '%d %d %d %f ', 2000, countG, countG+countY, PFA);

%Identify Green and Yellow Pixels for image 2005
countG = 0;
countY = 0;
[x, y, z] = size(I2005);
for i = 1:x
for j = 1:y
for k = 1:z
%Check for Green Pixels
if I2005(i, j, k)>=75 && I2005(i, j, k)<=115
countG = countG+1;
  
%Check for Yellow Pixels
elseif I2005(i, j, k)~=0 && I2005(i, j, k)~=240
countY = countY+1;
end
end
end
end

%Calculate PFA
PFA = countG*100/(countG+countY);

%Write to file
fprintf(fileID, '%d %d %d %f ', 2005, countG, countG+countY, PFA);

%Identify Green and Yellow Pixels for image 2010
countG = 0;
countY = 0;
[x, y, z] = size(I2010);
for i = 1:x
for j = 1:y
for k = 1:z
%Check for Green Pixels
if I2010(i, j, k)>=75 && I2010(i, j, k)<=115
countG = countG+1;
  
%Check for Yellow Pixels
elseif I2010(i, j, k)~=0 && I2010(i, j, k)~=240
countY = countY+1;
end
end
end
end

%Calculate PFA
PFA = countG*100/(countG+countY);

%Write to file
fprintf(fileID, '%d %d %d %f ', 2010, countG, countG+countY, PFA);

%Identify Green and Yellow Pixels for image 2020
countG = 0;
countY = 0;
[x, y, z] = size(I2020);
for i = 1:x
for j = 1:y
for k = 1:z
%Check for Green Pixels
if I2020(i, j, k)>=75 && I2020(i, j, k)<=115
countG = countG+1;
  
%Check for Yellow Pixels
elseif I2020(i, j, k)~=0 && I2020(i, j, k)~=240
countY = countY+1;
end
end
end
end

%Calculate PFA
PFA = countG*100/(countG+countY);

%Write to file
fprintf(fileID, '%d %d %d %f ', 2020, countG, countG+countY, PFA);


Screenshot of BorneoForestData.txt

MATLAB R2017a HOME PLOTS EDITOR lSearch Documentation Log In Find Files 凶Compare ▼ 연 Run Section comment 9e骗3, Go To New Open

Screenshot of Image:

Figure 1 File EditView Insert Tools Desktop Window Help 1960 1986 2000 2005 2010 2020 OType here to search TO ^ ヨ脈Qs ENG 03-01-2019 21

Add a comment
Know the answer?
Add Answer to:
4 MARKS QUEStION 3 Background You are part of a team working for the United Nations...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT