Sunspot data (NEW IMPROVED VERSION uses dlmread)
Contents
Read monthly sunspot data since 1749 until right now
Note that this will write the file sunspot_data.csv into your current working directory (specified at the top of your Matlab window). Change the current directory to the directory where your own m-files are (if you don't have write permission for the current directory you will get an error message).
url = 'http://www.sidc.be/silso/INFO/snmtotcsv.php'; filename = 'sunspot_data.csv'; websave(filename,url); % save data from web to file data = dlmread(filename,';'); % read file into array where ';' is delimiter t_midmonth = data(:,3); % column 3 is date of middle of month (in fraction of year) f = data(:,4); % sunspot numbers are in column 4 N = length(f); t = (0:N-1)/12; % we pretend data are taken at intervals of h=1/12 years plot(t,f,'.-'); axis tight % plot data xlabel('years since 1749') title('Monthly mean total sunspot number')
