Eng1060 assignment - calculate the coefficient of


QUESTION 1

Background

Climate change is a change in global or regional climate patterns, in particular a change apparent from the mid to late 20th century onwards and attributed largely to the increased levels of atmospheric carbon dioxide produced by the use of fossil fuels. The CO2 emissions (kt) from nine countries since year 1990 have been given in the text file ‘CO2_Emission.csv'. Each of the nine countries have been annotated with a country ID as given below:

Country ID

Country

1

Argentina

2

Australia

3

Belgium

4

China

5

Denmark

6

France

7

Malaysia

8

United Kingdom

9

United States

Q1a

Write Matlab scripts in a M-file (Assn_Q1.m) that will read data from ‘CO2_Emission.csv' (skip the text lines) and store the data in a matrix called ‘emission'. You shall not use import wizard to load the data from the text file.

Output the size of the matrix ‘emission' to the command window.

Then using the command ‘fprintf', to print out the data read from the text file following the format as follows:

CO2 emission (kt) by year

Country

1990

2000

2007

2008

2009

2010

2011

2012

2013

Argentina

112613.6

142136.6

175176.3

189107.2

179961.7

187919.1

191633.8

192359.8

189818.6

Australia

263705

329443.3

372090.5

385904.1

394792.9

372798.2

376710.9

375456.8

377906.4

Belgium

106049.6

115118.1

103545.1

104443.5

100259.4

107751.1

98917.33

92195.71

93618.51

China

2460744

3405180

6791805

7175659

7618684

8767878

9724591

10020745

10249463

Denmark

50230.57

51330.67

50256.24

46933.93

44510.05

46640.57

40645.03

36405.98

38067.13

France

375632.8

362090.6

368914.9

366069.3

351632.3

352769.1

331537.1

332956.3

333191

Malaysia

56592.81

125734.1

184816.8

204031.9

198802.7

218476.2

220405

218707.2

236510.5

United Kingdom

555924.5

541784.6

528425.7

520072.3

471400.2

493607.5

447935.1

467197.8

457472.9

United States

4823557

5701829

5794923

5622464

5274129

5408869

5305280

5115806

5186168

Q1b

Based on the data read from "CO2_Emission.csv", write Matlab scripts in the same M-file (written in Q1a) to:

i. Compute average CO2 emission for each of the nine countries.
ii. Compute average CO2 emission for each year
iii. Find out the country with highest average CO2 emission.
iv. Find out the year with highest average CO2 emission.
v. Find out how many countries with their CO2 emission higher than the average emission in year 2010

Use fprintf command to display your output.

Q1c

In the same M-file, write Matlab script to figure out the country with highest hike and largest decrement in the CO2 emission between year 1990 and 2013 respectively.

Use plot command to create a red line chart to show only the trend of CO2 emission for the country with highest hike between year 1990 and 2013.

In the same figure, plot another blue line chart to show only the trend of CO2 emission for the country with largest decrement between year 1990 and 2013.

Note:
You have to create two separate plots which are juxtaposed in a same figure for the task mentioned above. (Hint: Use subplot)

You need to include relevant title, x-axis & y-axis labels and the identified country name in the legend of the plots.

QUESTION 2

Background

Visible light is the reason we can see anything at all. Light moves as a wave, bouncing off objects so we are able to see them. Transmission of light is a phenomenon when light waves move all the way through a material without being absorbed. When light moves through a transparent (or semi-transparent) material, it can be transmitted, absorbed or reflected.

Experiments measuring the intensity of light transmitted through specimens of a transparent solid of various lengths are given in a text file (LightTransmit.txt).

Note: When attempting the each of the following tasks, ensure all units in your data are consistent, i.e S.I units. You cannot mix units.

Q2a
Write Matlab scripts in a M-file (Assn_Q2.m) that will read data from ‘LightTransmit.txt' (skip the text lines). Unfortunately, there are a few ‘noises' in the dataset (those data with It value higher than 10) and your Matlab program should skip those data as well and store the rest of the data in a matrix called ‘transmission_data'. You shall not use import wizard to load the data from the text file.

Then, use scatter command to create a scatterplot of data with intensity of light transmission, It, versus length of the transparent solid, L. You need to include appropriate title, legend and label of x-axis and y-axis in your plot.

Q2b

Based on the data distribution pattern observed in your scatter plot from Q2a, you predict the relationship between the intensity of light transmission and the transparent solid length could possibly be related by a polynomial equation. Perform a polynomial fit with a third order polynomial and make a plot for the polynomial equation which is overlaid with the scatter plot from Q2a. You should also create 50 interpolated data points onto your plot which are shown as red dots.

Hint: You may need to use the Matlab built-in functions polyfit and polyval for this task.

By observing the plot you made for the task above, your polynomial model seemingly fit the existing data points well. Try to create an extrapolated plot by extending the L upper limit to 0.1 m. Place your extrapolated plot in juxtaposition with your previous plot in this task Q2b (use subplot command). What could you observe and conclude from your extrapolated plot? Use fprintf command to show your brief description of your observation and conclusion (e.g. what's the problem you can find on the current polynomial model to relate the light transmission with the length of the transparent solid ? ) on command window.

Q2c

After having literature review, you find that the transmission of light through a transparent solid can be described by a theoretical equation:

IT = I0(1-R)2e-βL

IT = Intensity of light transmission I0 = Intensity of the incident beam
R = fraction of light which is reflected at the interface
β = absorption coefficient
L = the length of the transparent solid

Given that the intensity of the incident beam, I0 is 5 watts/m2. Use the data stored in matrix ‘transmission_data' which is done in Q1a to determine the absorption coefficient, β and fraction of light, R through curve fitting.

You shall not use Matlab built-in function for curve fitting such as polyfit, fit etc for this task. You have to write a user-defined regression function to obtain the absortion coefficient β and the fraction of light, R. The inputs to the function are two vectors (L and It in this context). The user-defined function must ensure the inputs of the vectors are of same length. If the two input vectors are not equal, it shall display an error message and terminate the program. The output arguments of this function are the coefficients a1 and a0 of a linear equation.

Hint: You may consider to adopt least-square linear regression to a non-linear model

Q2d

After performing curve fitting, make a line chart for the equation based on the β and R values you obtained from Q2c. Overlaid your line chart on a new scatter plot created based on the same dataset used in Q2a. The plot you create for this task shall be placed below the plot created in Q2b (use subplot).

Calculate the coefficient of determination and add it at the top of the plot as a text label using the Matlab command ‘text'.

Try to create another extrapolated plot for your current curve fitted model by extending the L upper limit to 0.1 m. Place your extrapolated plot in juxtaposition with your plot created in this task Q2d (use subplot command).

Q2e

Based on the equation given in question Q2c, use modified secant method to find an approximation of L when It is 3.3 watts/m2. You have to create another user-defined function (in separate function file) that use the modified secant method to find the root. Your user-defined function f shall include input arguments of a function handle, an initial guess, a small perturbation fraction and precision value. Test the user-defined function by prompting the user for an initial guess. You could presume the precision value is predefined as 0.001% and the perturbation fraction is 0.001. The function shall return the value of root. Display the root (which is the approximation of L) on command window with four decimal places.

Attachment:- LightTransmit - CO2_Emission.rar

Request for Solution File

Ask an Expert for Answer!!
MATLAB Programming: Eng1060 assignment - calculate the coefficient of
Reference No:- TGS01734138

Expected delivery within 24 Hours