clear all
%% Plotting script that shows the use of Boiler6 and the Electric heater over several years

datafile = "C:\Users\ehtor\OneDrive\Dokumenter\MasterNorskeSkog\ELKjelFiksDårlig.xlsx";

powerEl = xlsread(datafile, 'Sheet1', 'B3:B1630'); %Use of Electric heater
power6 = xlsread(datafile, 'Sheet1', 'D3:D1630'); %Use of Boiler6

[num, txt, timeDate_raw] = xlsread(datafile, 'Sheet1', 'A3:A1630'); %Reads date and time into the variable timeDate_raw
[num, txt, timeDate_raw2] = xlsread(datafile, 'Sheet1', 'A537:A1630'); %Reads date and time into the variable timeDate_raw

dateFormat = 'dd/mm/yyyy HH:MM:SS'; %Specify format of date and time import
dateConv = datenum(timeDate_raw, dateFormat); %Convert text string into date numbers
dateConv2 = datenum(timeDate_raw2, dateFormat); %Convert text string into date numbers

for i = 1:length(power6)
    if power6(i)<20
        power6(i)=nan;
        if i>534
            powerEl(i-534) = nan;
        end
    end
end

%% Plot

hold off
plot(dateConv, power6)
hold on
plot(dateConv2, powerEl)
%hold on
%plot(dateConv, 5.5*sin((dateConv-65)*2*pi/365)+33.5, 'r')
%refline(0,32)
dateFormat2 = 'dd/mm/yyyy';
datetick('x', dateFormat2)
axis([dateConv(1)-30, dateConv(end)+30, 0, 50])
set(gca,'TickDir','out');
set(gca,'box','off');
xlabel('Date') % x-axis label
ylabel('Power output [MW_{th}]')
legend('Boiler6','Electric heater')
set(findall(gca, 'Type', 'Line'),'LineWidth',1);