%This script calculates the maximum and minimum values in the pressures 
%and creates the bifurication map
%
%
% Written by: Knut Åge Meland
% email: knutagemeland@gmail.com
% Folders needs to be created before the figures can be saved.
% The script uses the custom globalfunction: save2pdf

%%
clear all
close all
clc
set(0,'defaultLineLineWidth', 2)
set(0,'DefaultAxesFontSize',14)
%% Generating the max_min data from the plot scripts

Loading={'bi5m','bi6m','bi8m','bi10m','bi12m','bi14m','bi20m', 'bi40m','bi60m','bi80m', 'bi100m'};
%loading data:
for i=1:length(Loading)
[Maxim(:,i) Minim(:,i) valve(i)]= max_min_func(Loading{i});
end

%% Plotting max and min in pressure
close all
for j=1:3 % 1=P1, 2=P2, 3= P3

figur_setup(2)
hold on

plot(valve, Maxim(j,:)); 
hold on
plot(valve, Minim(j,:),'-r'); 
hold off

xlabel('Valve opening [%]')
ylabel('Pressure [kPa]')
end

%% saving figure
for fig = [1,2,3];
    dir = 'c:\users\knutage\desktop\Master oppgave\Master_source\bilder\matlabfig\bifur_dia\';
    filename = ['figure', num2str(fig),'.jpg'];
    saveas(figure(fig), [dir filename]);
    filename = ['figure', num2str(fig),'.pdf'];
    save2pdf([dir, filename]);
end





