LAB2 - mgs(j,1 = year write the year to the data table end...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
% Garrett Lucas % LAB 2 % 2/12/10 %CVEN489 %Load the Average Price Data gpd = load('GasPriceData.txt'); % Load in the Motor Gasoline supply data mgs_vec = load('MGSupply.txt'); % Set up the conversion from column vector to data table n = length(mgs_vec); % counts number of data points date = num2str(mgs_vec(1,1)); % read the date and year_old = str2num(date(1:4))-1; % extract the year j = 0; % set a year counter % Create a blank location to store the data table mgs = zeros(floor(n/13),13); % Fill the table for i = 1:n date = num2str(mgs_vec(i,1)); year = str2num(date(1:4)); mon = str2num(date(5:6)); if year ~= year_old % check if the year has changed j = j+1; % update the year counter year_old = year; % store the new year value
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: mgs(j,1) = year; % write the year to the data table end if mon < 13 % month 13 is the yearly average; skip it mgs(j,mon+1) = mgs_vec(i,2); % store the data in the table end end %Plot 1 x1 = gpd(1:33,1); y1 = gpd(1:33,2); y2 = gpd(1:33,7); plot (x1,y1,'kx-',x1,y2,'ro-'); title('Rise of gas prices for January and June'); xlabel('Year'); ylabel('Gasoline Price per Gallon (USD)'); legend('January','June'); %Plot 2 x2 = mgs(1:33,1); y3 = mgs(1:33,2); y4 = mgs(1:33,7); plot(x2,y3, 'kx-', x2,y4,'ro-'); title('Rise of gasoline production in barrls per day for January and June'); xlabel('Year'); ylabel('Barrels per day'); legend('January','June');...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online