diff --git a/Problem 2/problem1.m b/Problem 2/problem1.m new file mode 100644 index 0000000..4be2a10 --- /dev/null +++ b/Problem 2/problem1.m @@ -0,0 +1,8 @@ +A_66=zeros(6:6); +for i=1:6; + j=1:6; + A_66(i,j)=i*j; +end + +fprintf('mean of A_66 = %1.2f\nstdev of A_66 = %1.2f\n',mean(A_66(:)),std(A_66(:))) + diff --git a/Problem 3/Thumbs.db b/Problem 3/Thumbs.db new file mode 100644 index 0000000..dacc42a Binary files /dev/null and b/Problem 3/Thumbs.db differ diff --git a/Problem 4/US_energy_by_sector.csv b/Problem 4/US_energy_by_sector.csv new file mode 100644 index 0000000..bceb331 --- /dev/null +++ b/Problem 4/US_energy_by_sector.csv @@ -0,0 +1,70 @@ +Annual Total,Primary Energy Consumed by the Residential Sector,Total Energy Consumed by the Residential Sector,Primary Energy Consumed by the Commercial Sector,Total Energy Consumed by the Commercial Sector,Primary Energy Consumed by the Industrial Sector,Total Energy Consumed by the Industrial Sector,Primary Energy Consumed by the Transportation Sector,Total Energy Consumed by the Transportation Sector,Primary Energy Consumed by the Electric Power Sector,Energy Consumption Balancing Item,Primary Energy Consumption Total +,(Trillion Btu),(Trillion Btu),(Trillion Btu),(Trillion Btu),(Trillion Btu),(Trillion Btu),(Trillion Btu),(Trillion Btu),(Trillion Btu),(Trillion Btu),(Trillion Btu) +1949,4460.434,5599.25,2668.869,3668.816,12633.386,14723.587,7879.509,7990.015,4339.47,-0.165,31981.503 +1950,4829.337,5988.553,2834.094,3893.298,13889.626,16241.423,8383.407,8492.473,4679.283,0.021,34615.768 +1951,5104.476,6380.193,2737.684,3873.226,15127.368,17678.532,8933.484,9041.892,5070.83,0.188,36974.03 +1952,5158.193,6560.243,2672.911,3873.385,14671.564,17311.362,8906.891,9002.752,5338.183,0.082,36747.825 +1953,5052.515,6558.748,2512.376,3770.982,15339.206,18211.754,9030.055,9123.022,5730.355,-0.039,37664.468 +1954,5262.307,6846.058,2457.578,3732.921,14317.111,17157.695,8822.551,8902.617,5779.745,0.091,36639.382 +1955,5607.812,7277.988,2561.252,3895.14,16102.98,19484.608,9474.426,9550.205,6461.471,0.03,40207.971 +1956,5839.383,7662.725,2606.854,4022.859,16575.573,20209.479,9790.32,9859.364,6942.296,-0.174,41754.252 +1957,5743.9,7712,2449.291,3960.787,16526.394,20218.258,9836.694,9896.269,7231.035,-0.128,41787.186 +1958,6125.37,8200.674,2557.205,4119.156,15812.501,19321.087,9952.005,10004.101,7197.936,0.011,41645.028 +1959,6188.311,8411.866,2649.39,4372.186,16536.173,20333.201,10297.614,10348.53,7794.295,-0.061,43465.722 +1960,6650.835,9039.418,2722.565,4609.4,16995.524,20841.687,10559.596,10595.943,8157.929,0.007,45086.455 +1961,6775.61,9286.024,2764.986,4727.663,17012.051,20955.128,10733.732,10769.126,8451.561,-0.103,45737.837 +1962,7079.711,9782.42,2923.873,5036.386,17610.477,21788.192,11184.889,11219.481,9027.528,-0.042,47826.437 +1963,7089.813,9988.479,2921.18,5250.646,18388.155,22751.19,11620.029,11653.755,9624.895,0.124,49644.195 +1964,7111.751,10240.574,2977.204,5465.993,19449.358,24111.354,11963.238,11997.007,10313.377,-0.14,51814.788 +1965,7279.422,10639.387,3176.893,5845.423,20147.629,25097.614,12398.707,12432.456,11012.229,0.121,54015.001 +1966,7500.386,11168.63,3408.944,6324.047,21055.032,26421.623,13067.522,13100.235,11982.651,-0.203,57014.332 +1967,7711.36,11639.275,3767.693,6899.205,21012.944,26614.298,13718.194,13752.076,12694.663,-0.333,58904.521 +1968,7932.745,12336.29,3899.46,7329.032,21868.985,27883.171,14831.225,14865.775,13881.853,0.238,62414.507 +1969,8242.797,13169.156,4085.279,7833.219,22647.702,29105.4,15471.249,15506.506,15167.253,-0.26,65614.02 +1970,8322.406,13765.758,4236.666,8346.295,22963.9,29627.901,16061.89,16098.249,16253.34,0.123,67838.325 +1971,8427.451,14246.2,4323.753,8720.954,22719.816,29585.943,16694.335,16730.053,17117.795,-0.307,69282.843 +1972,8627.379,14857.045,4411.961,9183.416,23516.505,30930.189,17682.135,17717.291,18449.961,-0.075,72687.867 +1973,8225.308,14897.351,4422.793,9542.957,24720.398,32623.268,18577.224,18612.78,19730.632,7.334,75683.69 +1974,7907.91,14654.336,4259.084,9393.324,23795.853,31787.187,18087.175,18120.419,19905.245,7.102,73962.369 +1975,7989.629,14813.4,4059.188,9492.492,21434.365,29413.018,18210.492,18245.003,20270.238,0.64,71964.553 +1976,8391.135,15410.259,4371.469,10063.334,22665.169,31392.821,19066.676,19100.798,21472.764,7.613,75974.826 +1977,8193.619,15661.713,4258.152,10207.599,23165.296,32263.009,19786.215,19821.59,22550.63,7.418,77961.33 +1978,8259.943,16132.287,4308.941,10511.88,23244.026,32687.556,20582.761,20617.064,23553.115,1.619,79950.406 +1979,7918.91,15812.724,4365.844,10648.024,24191.815,33924.74,20437.252,20471.532,23943.198,1.564,80858.584 +1980,7439.405,15753.38,4104.984,10578.258,22594.829,32039.419,19659.098,19696.69,24269.431,-1.08,78066.668 +1981,7045.285,15261.544,3837.025,10615.891,21318.163,30711.561,19477.771,19514.013,24424.767,2.767,76105.776 +1982,7146.587,15530.937,3864.013,10860.337,19052.815,27614.494,19052.169,19089.228,23979.412,4.189,73099.185 +1983,6831.823,15425.021,3840.293,10938.376,18547.898,27427.759,19134.104,19176.615,24613.652,2.796,72970.566 +1984,7210.899,15959.563,4000.779,11443.89,20173.625,29569.887,19608.586,19655.566,25635.017,2.794,76631.701 +1985,7148.219,16041.334,3732.156,11451.231,19442.85,28815.809,20041.466,20087.913,26031.597,-3.903,76392.385 +1986,6906.19,15975.109,3692.736,11606.106,19077.948,28273.554,20739.924,20788.785,26226.756,3.452,76647.005 +1987,6923.374,16263.214,3774.113,11946.009,19953.132,29378.886,21418.773,21468.88,26987.596,-2.533,79054.456 +1988,7356.785,17132.613,3993.898,12578.091,20861.787,30677.381,22266.602,22317.722,28226.734,3.365,82709.172 +1989,7566.171,17784.963,4043.125,13193.587,20873.917,31319.92,22424.115,22477.945,29869.088,8.998,84785.414 +1990,6556.428,16944.421,3896.027,13319.94,21180.071,31809.805,22366.211,22419.624,30495.053,-9.336,84484.454 +1991,6745.778,17419.328,3945.518,13499.969,20824.479,31399.34,22064.827,22117.987,30856.021,0.595,84437.218 +1992,6949.119,17354.771,3990.811,13441.084,21756.37,32570.884,22362.755,22415.073,30722.757,0.356,85782.168 +1993,7144.96,18216.519,3972.879,13819.793,21752.384,32627.877,22658.632,22711.73,31847.065,-10.49,87365.429 +1994,6976.233,18110.262,4016.29,14097.332,22391.808,33520.313,23309.995,23365.133,32398.714,-5.698,89087.342 +1995,6934.049,18516.657,4100.407,14689.92,22718.332,33969.76,23795.86,23851.129,33478.818,3.148,91030.614 +1996,7464.004,19501.837,4273.346,15171.9,23408.972,34903.242,24384.465,24439.208,34485.4,4.343,94020.53 +1997,7030.243,18962.257,4295.445,15681.208,23685.303,35199.392,24696.914,24751.338,34886.291,6.145,94600.34 +1998,6410.425,18951.921,4004.782,15967.514,23175.735,34841.564,25205.052,25260.114,36225.117,-3.374,95017.738 +1999,6771.791,19553.514,4053.402,16376.271,22949.091,34762.838,25892.262,25949.489,36975.567,6.282,96648.394 +2000,7155.591,20421.044,4278.142,17175.373,22823.293,34662.498,26495.46,26555.329,38061.759,2.304,98816.549 +2001,6863.77,20037.595,4084.524,17136.778,21792.891,32719.226,26219.394,26282.153,37215.174,-6.079,96169.673 +2002,6906.777,20785.797,4132.046,17345.751,21798.163,32661.068,26785.225,26845.749,38016.154,5.118,97643.483 +2003,7232.351,21119.325,4298.303,17346.105,21533.687,32553.077,26826.053,26900.175,38028.287,-1.172,97917.51 +2004,6986.583,21081.393,4232.181,17655.44,22411.443,33515.623,27763.966,27842.772,38701.055,-5.519,100089.709 +2005,6900.676,21612.654,4052.223,17853.401,21410.38,32441.503,28199.102,28280.349,39625.526,-0.175,100187.732 +2006,6154.405,20670.333,3747.325,17707.151,21528.97,32390.757,28637.627,28716.65,39416.564,-0.385,99484.506 +2007,6588.823,21519.009,3922.429,18252.874,21362.917,32385.234,28770.701,28858.342,40370.589,-0.684,101014.775 +2008,6888.713,21667.652,4099.806,18402.104,20528.139,31334.246,27404.332,27486.253,39969.266,0.534,98890.79 +2009,6632.712,21077.403,4055.45,17887.264,18755.909,28465.906,26604.849,26687.066,38068.718,0.021,94117.66 +2010,6540.352,21794.609,4022.863,18058.336,20277.892,30525.641,26977.695,27059.072,39618.856,6.87,97444.528 +2011,6391.687,21300.507,4062.532,17978.581,20455.645,30843.144,26631.724,26712.116,39292.761,7.527,96841.877 +2012,5672.28,19858.131,3725.389,17421.903,20741.662,30914.845,26143.711,26219.258,38131.096,2.169,94416.307 +2013,6704.59,21067.577,4163.536,17932.018,21262.802,31409.399,26671.26,26749.778,38356.585,-1.334,97157.439 +2014,6989.953,21429.25,4380.194,18254.625,21407.161,31643.241,26916.88,26996.48,38629.409,5.544,98329.141 +2015,6358.889,20511.786,4435.897,18151.889,21383.449,31327.169,27278.22,27355.195,37889.585,18.969,97365.008 +2016,6082.769,20413.099,4368.19,18212.038,21308.022,30841.268,27848.936,27925.291,37783.779,2.575,97394.271 diff --git a/Problem 4/US_energy_by_sector.m b/Problem 4/US_energy_by_sector.m new file mode 100644 index 0000000..bceb331 --- /dev/null +++ b/Problem 4/US_energy_by_sector.m @@ -0,0 +1,70 @@ +Annual Total,Primary Energy Consumed by the Residential Sector,Total Energy Consumed by the Residential Sector,Primary Energy Consumed by the Commercial Sector,Total Energy Consumed by the Commercial Sector,Primary Energy Consumed by the Industrial Sector,Total Energy Consumed by the Industrial Sector,Primary Energy Consumed by the Transportation Sector,Total Energy Consumed by the Transportation Sector,Primary Energy Consumed by the Electric Power Sector,Energy Consumption Balancing Item,Primary Energy Consumption Total +,(Trillion Btu),(Trillion Btu),(Trillion Btu),(Trillion Btu),(Trillion Btu),(Trillion Btu),(Trillion Btu),(Trillion Btu),(Trillion Btu),(Trillion Btu),(Trillion Btu) +1949,4460.434,5599.25,2668.869,3668.816,12633.386,14723.587,7879.509,7990.015,4339.47,-0.165,31981.503 +1950,4829.337,5988.553,2834.094,3893.298,13889.626,16241.423,8383.407,8492.473,4679.283,0.021,34615.768 +1951,5104.476,6380.193,2737.684,3873.226,15127.368,17678.532,8933.484,9041.892,5070.83,0.188,36974.03 +1952,5158.193,6560.243,2672.911,3873.385,14671.564,17311.362,8906.891,9002.752,5338.183,0.082,36747.825 +1953,5052.515,6558.748,2512.376,3770.982,15339.206,18211.754,9030.055,9123.022,5730.355,-0.039,37664.468 +1954,5262.307,6846.058,2457.578,3732.921,14317.111,17157.695,8822.551,8902.617,5779.745,0.091,36639.382 +1955,5607.812,7277.988,2561.252,3895.14,16102.98,19484.608,9474.426,9550.205,6461.471,0.03,40207.971 +1956,5839.383,7662.725,2606.854,4022.859,16575.573,20209.479,9790.32,9859.364,6942.296,-0.174,41754.252 +1957,5743.9,7712,2449.291,3960.787,16526.394,20218.258,9836.694,9896.269,7231.035,-0.128,41787.186 +1958,6125.37,8200.674,2557.205,4119.156,15812.501,19321.087,9952.005,10004.101,7197.936,0.011,41645.028 +1959,6188.311,8411.866,2649.39,4372.186,16536.173,20333.201,10297.614,10348.53,7794.295,-0.061,43465.722 +1960,6650.835,9039.418,2722.565,4609.4,16995.524,20841.687,10559.596,10595.943,8157.929,0.007,45086.455 +1961,6775.61,9286.024,2764.986,4727.663,17012.051,20955.128,10733.732,10769.126,8451.561,-0.103,45737.837 +1962,7079.711,9782.42,2923.873,5036.386,17610.477,21788.192,11184.889,11219.481,9027.528,-0.042,47826.437 +1963,7089.813,9988.479,2921.18,5250.646,18388.155,22751.19,11620.029,11653.755,9624.895,0.124,49644.195 +1964,7111.751,10240.574,2977.204,5465.993,19449.358,24111.354,11963.238,11997.007,10313.377,-0.14,51814.788 +1965,7279.422,10639.387,3176.893,5845.423,20147.629,25097.614,12398.707,12432.456,11012.229,0.121,54015.001 +1966,7500.386,11168.63,3408.944,6324.047,21055.032,26421.623,13067.522,13100.235,11982.651,-0.203,57014.332 +1967,7711.36,11639.275,3767.693,6899.205,21012.944,26614.298,13718.194,13752.076,12694.663,-0.333,58904.521 +1968,7932.745,12336.29,3899.46,7329.032,21868.985,27883.171,14831.225,14865.775,13881.853,0.238,62414.507 +1969,8242.797,13169.156,4085.279,7833.219,22647.702,29105.4,15471.249,15506.506,15167.253,-0.26,65614.02 +1970,8322.406,13765.758,4236.666,8346.295,22963.9,29627.901,16061.89,16098.249,16253.34,0.123,67838.325 +1971,8427.451,14246.2,4323.753,8720.954,22719.816,29585.943,16694.335,16730.053,17117.795,-0.307,69282.843 +1972,8627.379,14857.045,4411.961,9183.416,23516.505,30930.189,17682.135,17717.291,18449.961,-0.075,72687.867 +1973,8225.308,14897.351,4422.793,9542.957,24720.398,32623.268,18577.224,18612.78,19730.632,7.334,75683.69 +1974,7907.91,14654.336,4259.084,9393.324,23795.853,31787.187,18087.175,18120.419,19905.245,7.102,73962.369 +1975,7989.629,14813.4,4059.188,9492.492,21434.365,29413.018,18210.492,18245.003,20270.238,0.64,71964.553 +1976,8391.135,15410.259,4371.469,10063.334,22665.169,31392.821,19066.676,19100.798,21472.764,7.613,75974.826 +1977,8193.619,15661.713,4258.152,10207.599,23165.296,32263.009,19786.215,19821.59,22550.63,7.418,77961.33 +1978,8259.943,16132.287,4308.941,10511.88,23244.026,32687.556,20582.761,20617.064,23553.115,1.619,79950.406 +1979,7918.91,15812.724,4365.844,10648.024,24191.815,33924.74,20437.252,20471.532,23943.198,1.564,80858.584 +1980,7439.405,15753.38,4104.984,10578.258,22594.829,32039.419,19659.098,19696.69,24269.431,-1.08,78066.668 +1981,7045.285,15261.544,3837.025,10615.891,21318.163,30711.561,19477.771,19514.013,24424.767,2.767,76105.776 +1982,7146.587,15530.937,3864.013,10860.337,19052.815,27614.494,19052.169,19089.228,23979.412,4.189,73099.185 +1983,6831.823,15425.021,3840.293,10938.376,18547.898,27427.759,19134.104,19176.615,24613.652,2.796,72970.566 +1984,7210.899,15959.563,4000.779,11443.89,20173.625,29569.887,19608.586,19655.566,25635.017,2.794,76631.701 +1985,7148.219,16041.334,3732.156,11451.231,19442.85,28815.809,20041.466,20087.913,26031.597,-3.903,76392.385 +1986,6906.19,15975.109,3692.736,11606.106,19077.948,28273.554,20739.924,20788.785,26226.756,3.452,76647.005 +1987,6923.374,16263.214,3774.113,11946.009,19953.132,29378.886,21418.773,21468.88,26987.596,-2.533,79054.456 +1988,7356.785,17132.613,3993.898,12578.091,20861.787,30677.381,22266.602,22317.722,28226.734,3.365,82709.172 +1989,7566.171,17784.963,4043.125,13193.587,20873.917,31319.92,22424.115,22477.945,29869.088,8.998,84785.414 +1990,6556.428,16944.421,3896.027,13319.94,21180.071,31809.805,22366.211,22419.624,30495.053,-9.336,84484.454 +1991,6745.778,17419.328,3945.518,13499.969,20824.479,31399.34,22064.827,22117.987,30856.021,0.595,84437.218 +1992,6949.119,17354.771,3990.811,13441.084,21756.37,32570.884,22362.755,22415.073,30722.757,0.356,85782.168 +1993,7144.96,18216.519,3972.879,13819.793,21752.384,32627.877,22658.632,22711.73,31847.065,-10.49,87365.429 +1994,6976.233,18110.262,4016.29,14097.332,22391.808,33520.313,23309.995,23365.133,32398.714,-5.698,89087.342 +1995,6934.049,18516.657,4100.407,14689.92,22718.332,33969.76,23795.86,23851.129,33478.818,3.148,91030.614 +1996,7464.004,19501.837,4273.346,15171.9,23408.972,34903.242,24384.465,24439.208,34485.4,4.343,94020.53 +1997,7030.243,18962.257,4295.445,15681.208,23685.303,35199.392,24696.914,24751.338,34886.291,6.145,94600.34 +1998,6410.425,18951.921,4004.782,15967.514,23175.735,34841.564,25205.052,25260.114,36225.117,-3.374,95017.738 +1999,6771.791,19553.514,4053.402,16376.271,22949.091,34762.838,25892.262,25949.489,36975.567,6.282,96648.394 +2000,7155.591,20421.044,4278.142,17175.373,22823.293,34662.498,26495.46,26555.329,38061.759,2.304,98816.549 +2001,6863.77,20037.595,4084.524,17136.778,21792.891,32719.226,26219.394,26282.153,37215.174,-6.079,96169.673 +2002,6906.777,20785.797,4132.046,17345.751,21798.163,32661.068,26785.225,26845.749,38016.154,5.118,97643.483 +2003,7232.351,21119.325,4298.303,17346.105,21533.687,32553.077,26826.053,26900.175,38028.287,-1.172,97917.51 +2004,6986.583,21081.393,4232.181,17655.44,22411.443,33515.623,27763.966,27842.772,38701.055,-5.519,100089.709 +2005,6900.676,21612.654,4052.223,17853.401,21410.38,32441.503,28199.102,28280.349,39625.526,-0.175,100187.732 +2006,6154.405,20670.333,3747.325,17707.151,21528.97,32390.757,28637.627,28716.65,39416.564,-0.385,99484.506 +2007,6588.823,21519.009,3922.429,18252.874,21362.917,32385.234,28770.701,28858.342,40370.589,-0.684,101014.775 +2008,6888.713,21667.652,4099.806,18402.104,20528.139,31334.246,27404.332,27486.253,39969.266,0.534,98890.79 +2009,6632.712,21077.403,4055.45,17887.264,18755.909,28465.906,26604.849,26687.066,38068.718,0.021,94117.66 +2010,6540.352,21794.609,4022.863,18058.336,20277.892,30525.641,26977.695,27059.072,39618.856,6.87,97444.528 +2011,6391.687,21300.507,4062.532,17978.581,20455.645,30843.144,26631.724,26712.116,39292.761,7.527,96841.877 +2012,5672.28,19858.131,3725.389,17421.903,20741.662,30914.845,26143.711,26219.258,38131.096,2.169,94416.307 +2013,6704.59,21067.577,4163.536,17932.018,21262.802,31409.399,26671.26,26749.778,38356.585,-1.334,97157.439 +2014,6989.953,21429.25,4380.194,18254.625,21407.161,31643.241,26916.88,26996.48,38629.409,5.544,98329.141 +2015,6358.889,20511.786,4435.897,18151.889,21383.449,31327.169,27278.22,27355.195,37889.585,18.969,97365.008 +2016,6082.769,20413.099,4368.19,18212.038,21308.022,30841.268,27848.936,27925.291,37783.779,2.575,97394.271 diff --git a/Problem 4/US_energy_by_sector_code.m b/Problem 4/US_energy_by_sector_code.m new file mode 100644 index 0000000..e20641b --- /dev/null +++ b/Problem 4/US_energy_by_sector_code.m @@ -0,0 +1,27 @@ +data=dlmread('US_energy_by_sector.csv',',',2,0); +h=figure(); +plot(data(:,1),data(:,3),data(:,1),data(:,9)); +%plotting residential energy consumption and transportational energy +%consumption from 1949 to 2016 in trillions of BTUs +set(0, 'defaultAxesFontSize', 16) +set(0,'defaultTextFontSize',14) +set(0,'defaultLineLineWidth',3) +set(gcf, 'Position', [200, 200, 1000, 800]) +xlabel('Time (years)') +ylabel('Total Energy Consumed (trillions of BTUs)') +legend('Residential','Transportation','Location','northwest') +title('US Energy Consumption from 1949 to 2016') +saveas(h,'figure_01.png') + +rescum=cumsum(data(:,3))./1000000;%cumulative sum of residential energy +%consumption in quintillions of BTUs +transcum=cumsum(data(:,9))./1000000;%cumulative sum of transportational +%energy consumption in quintillions of BTUs +h=figure(); +plot(data(:,1),rescum,data(:,1),transcum) +set(gcf, 'Position', [500, 200, 1000, 800]) +xlabel('Time (years)') +ylabel('Total Energy Consumed (quintillions of BTUs)') +legend('Residential','Transportation','Location','northwest') +title('Cumulative US Energy Consumption from 1949 to 2016') +saveas(h,'figure_02.png') \ No newline at end of file diff --git a/Problem 4/figure_01.png b/Problem 4/figure_01.png new file mode 100644 index 0000000..5f214fe Binary files /dev/null and b/Problem 4/figure_01.png differ diff --git a/Problem 4/figure_02.png b/Problem 4/figure_02.png new file mode 100644 index 0000000..d2ec442 Binary files /dev/null and b/Problem 4/figure_02.png differ diff --git a/README.md b/README.md index 0bae83d..a4514ea 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,55 @@ # Answer to Homework Question I hope to learn how to perform MATLAB functions more easily. + +#Problem 3 +```MATLAB +A_66=zeros(6:6); +for i=1:6; + j=1:6; + A_66(i,j)=i*j; +end +fprintf('mean of A_66 = %1.2f\nstdev of A_66 = %1.2f\n',mean(A_66(:)),std(A_66(:))) +``` +Outputs: + +mean of A_66 = 12.25 + +stdev of A_66 = 9.07 + +#Problem 4 +```MATLAB +data=dlmread('US_energy_by_sector.csv',',',2,0); +h=figure(); +plot(data(:,1),data(:,3),data(:,1),data(:,9)); +%plotting residential energy consumption and transportational energy +%consumption from 1949 to 2016 in trillions of BTUs +set(0, 'defaultAxesFontSize', 16) +set(0,'defaultTextFontSize',14) +set(0,'defaultLineLineWidth',3) +set(gcf, 'Position', [200, 200, 1000, 800]) +xlabel('Time (years)') +ylabel('Total Energy Consumed (trillions of BTUs)') +legend('Residential','Transportation','Location','northwest') +title('US Energy Consumption from 1949 to 2016') +saveas(h,'figure_01.png') +``` +![US Energy Use per Year from 1949-2016](./figure_01.png) + + +```MATLAB +rescum=cumsum(data(:,3))./1000000;%cumulative sum of residential energy +%consumption in quintillions of BTUs +transcum=cumsum(data(:,9))./1000000;%cumulative sum of transportational +%energy consumption in quintillions of BTUs +h=figure(); +plot(data(:,1),rescum,data(:,1),transcum) +set(gcf, 'Position', [500, 200, 1000, 800]) +xlabel('Time (years)') +ylabel('Total Energy Consumed (quintillions of BTUs)') +legend('Residential','Transportation','Location','northwest') +title('Cumulative US Energy Consumption from 1949 to 2016') +saveas(h,'figure_02.png') +``` + +#Problem 5 (Velocity and Acceleration)