Analyzing gas prices data

Contents

Double click on "gas1.xls" to import data

[data, textdata] = xlsread('Gas1.xls');

Back to top

Extract dates

dates = textdata(2:end,1);
disp(dates(1:5))
    '01/01/1996'
    '08/01/1996'
    '15/01/1996'
    '22/01/1996'
    '29/01/1996'

Back to top

Extract category names

cats = textdata(1, 2:end)
cats = 

    'Belgium '    'France'    'Germany'    'Italy'    'Netherlands'    'UK'    'US'

Back to top

Keep track of the size of the original matrix

originalsize = size(data)
originalsize =

   608     7

Back to top

Smooth the data (turning it into a vector)

data = smooth(data);
size(data)
ans =

        4256           1

Back to top

Restore the data's shape as a matrix

data = reshape(data, originalsize);
disp(data(1:5,:))
    3.9555    3.9330    4.0732    3.8908    4.3223    3.1996    1.2680
    3.9270    3.9193    4.0321    3.9310    4.3117    3.2321    1.2767
    3.8936    3.8847    3.9926    3.9340    4.2746    3.1904    1.2807
    3.8426    3.8309    3.9554    3.9057    4.2239    3.0937    1.2783
    3.8165    3.8004    3.9478    3.9010    4.2021    3.0311    1.2729

Back to top

Plot

plot(data)
set(gca, 'xTickLabel', dates);
legend(cats, 'Location', 'Best');
set(gcf, 'Position', [100 100 800 600]);

Plot example

Back to top

Look for correlations

corr(data)
ans =

    1.0000    0.9930    0.9823    0.9934    0.9856    0.9033    0.9416
    0.9930    1.0000    0.9904    0.9953    0.9928    0.9203    0.9503
    0.9823    0.9904    1.0000    0.9933    0.9966    0.9083    0.9377
    0.9934    0.9953    0.9933    1.0000    0.9939    0.9116    0.9369
    0.9856    0.9928    0.9966    0.9939    1.0000    0.9171    0.9433
    0.9033    0.9203    0.9083    0.9116    0.9171    1.0000    0.9320
    0.9416    0.9503    0.9377    0.9369    0.9433    0.9320    1.0000

Back to top


Published with MATLAB® 7.4