How to import current CO2 data from NOAA
Column 4 of the data ("average") contains the monthly mean CO2 mole fraction determined from daily averages. The mole fraction of CO2, expressed as parts per million (ppm) is the number of molecules of CO2 in every one million molecules of dried air (water vapor removed).
url = 'https://gml.noaa.gov/webdata/ccgg/trends/co2/co2_mm_mlo.txt'; % URL for monthly mean data
str = urlread(url); % read data from url into string
% str contains 8 numbers per line, comment lines start with "#"
data = textscan(str,'%f %f %f %f %f %f %f %f','CommentStyle','#'); % data is cell array
data = cell2mat(data); % convert to array
% data is now N by 8 array where N is the number of months available
N = size(data,1); % number of months
t = (1:N)'; % column vector with 1,...,N
conc = data(:,4); % vector of monthly CO2 averages from column 4
xlabel('months since March 1958'); title('CO2 concentration (mole fraction in ppm)')
- t is a vector [1;2;...] containing number of month starting March 1958
- conc is a vector with the CO2 concentration for this month