PHYS5033
Useful MATLAB commands
>> a = b * c; % matrix multiplication
>> d = a’; % matrix transposition
>> col_sum = sum(a,1); % column summation operator
>> row_sum = sum(a,2); % row summation operator
>> load(‘T.mat’); % bring a saved matrix into the workspace
>> y = readmatrix(‘my_exp.csv’); % read a matrix into the workspace
Using scripts to run multiple commands
• Create a new folder on your computer
• Give it a name, for example “PHYS5033_MATLAB”
• Download and unzip the data files from Week 12 or 13 “Lecture Resources”
• Open MATLAB
• Navigate to the folder into which you have saved the data file
• Type the following in the command window:
>> edit PHYS5033_practice
Putting knowledge into practice
Sustainability Assessment of an economy
Follow the steps below to calculate the total carbon footprint of an economy in MATLAB.
1. Load the files T, v, y and Q in the workspace.
2. Calculate the total input and total output of the economy.
3. Test if your input-output system is balanced.
4. Calculate the direct intensity q
5. Calculate the A matrix and the Leontief inverse L.
6. Calculate the total intensity m
7. Calculate the total footprint by sector.
8. Calculate the total footprint of the economy.
HINT: eye (for making identity matrices); inv (for taking an inverse)
Putting knowledge into practice
Sustainability Assessment of an individual’s expenditure
Step 1 - Create an expenditure vector
Tips:
• Focus on the direct expenditure, not any potential upstream or downstream expenditure. The L matrix takes care of that for us.
• Rent is usually paid to a real estate agent, but may be to the University if you are in Student Accommodation
• Purchasing second-hand items may mean that your expenditure is directed at community groups
• Beware of allocating all expenditure to the Retail sector
Follow the steps below to calculate the carbon footprint of an individual in MATLAB.
1. Load the files ‘IntermediateDemand.mat’, ‘Output.mat’, and ‘Satellite.mat’ in the workspace
2. Read in the .csv file with the individual’s expenditure (1 column of numbers only)
3. Calculate the direct intensity q
4. Calculate the A matrix and the Leontief inverse L
5. Calculate the total intensity m
6. Calculate the individual’s total footprint
7. Calculate the individual’s footprint by sector
HINT: eye (for making identity matrices); inv (for taking an inverse)
版权所有:留学生编程辅导网 2020 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。