%vymazani promennych z pameti
%zavreni vsech oken
%vycisteni prikazoveho radku (okna)
clear all
close all
clc

%nacteni datovych matic ulozenych v souboru forest.mat (vytvoreny spustenim
%souboru forest_data.m
load forest.mat

    defor = FOREST(:,1);
    pop   = FOREST(:,2);
    crop  = FOREST(:,3);
    pastur= FOREST(:,4);
 
%% Vykresleni dat   
 figure
    subplot(2,1,1)
    plot(crop,defor,'r*')
    title('Pokles zalesneni a zmena rozlohy orne pudy')
    ylabel('Procentni pokles za rok')
    xlabel('Zmena rozlohy orne pudy (%)')
    
    subplot(2,1,2)
    plot(pastur,defor,'bx')
    title('Pokles zalesneni a zmena rozlohy pastvin')
    ylabel('Procentni pokles za rok')
    xlabel('Zmena rozlohy pastvin (%)')
    

%% Popisne statistiky    
fprintf('\n\n');
fprintf('*********\n');
fprintf('Priklad 4\n');
fprintf('*********\n');
fprintf('Popisne statistiky\n');
fprintf('                     Crop     Pasture\n');
fprintf('Prumer             %8.4f  %8.4f\n',[mean(crop),mean(pastur)]);
fprintf('Rozptyl            %8.4f  %8.4f\n',[var(crop,1),var(pastur,1)]);
fprintf('Rozptyl vyb.       %8.4f  %8.4f\n',[var(crop),var(pastur)]);
fprintf('Sm. odchylka       %8.4f  %8.4f\n',[std(crop,1),std(pastur,1)]);
fprintf('Sm. odchylka vyb.  %8.4f  %8.4f\n',[std(crop),std(pastur)]);
fprintf('Min                %8.4f  %8.4f\n',[min(crop),min(pastur)]);
fprintf('Max                %8.4f  %8.4f\n',[max(crop),max(pastur)]);
fprintf('   ------------------------------------\n\n');

%% Korelacni matice pro FOREST
corFOREST = corr(FOREST);

fprintf('\n\n');
fprintf('*********\n');
fprintf('Priklad 8\n');
fprintf('*********\n');
fprintf('Korelacni matice FOREST\n');
fprintf('           Deforest   Pop       Crop      Pasture\n');
fprintf('Deforest  %8.4f  \n',corFOREST(1,1));
fprintf('Pop       %8.4f  %8.4f  \n',corFOREST(2,1:2));
fprintf('Crop      %8.4f  %8.4f  %8.4f  \n',[corFOREST(3,1:3)]);
fprintf('Pasture   %8.4f  %8.4f  %8.4f  %8.4f\n',corFOREST(4,1:4));
fprintf('   ------------------------------------\n\n');    