clear;
gridaccuracy=31;
dominance="S";
clutch_size_max=[100 100 100 100];
larval_weekly_survival=0.85;
T=0.25; 
L=1; 
dev_dist="dev_unif";
init_pop=10000;
tmax=44;
ddparameter=[1e-8*1 1e-8 1e-8]; 
hybrid_fitness=NaN ;% Only difference among the 3 files producing fig S1 and fig S2

density_dependence="A";
niche_shift=[4 6];
b=[0.1 1 NaN]; 

figure(1); clf;
columns=length(niche_shift);
rows=length(b);
subplotno=0;

for i=1:rows
    for j=1:columns
        subplotno=subplotno+1;
        [i j]
        gridaccuracy=31;
        [x,y,z]=computetriangle(gridaccuracy,dominance,clutch_size_max,density_dependence,ddparameter,hybrid_fitness,larval_weekly_survival,b(i),T,L,dev_dist,init_pop,tmax,niche_shift(j));
        eval(['x' int2str(i) int2str(j) '=x;']);
        eval(['y' int2str(i) int2str(j) '=y;']);
        eval(['z' int2str(i) int2str(j) '=z;']);
            subplotno=subplotno+1;
            
        gridaccuracy=31*3;
        [x,y,z]=computetriangle(gridaccuracy,dominance,clutch_size_max,density_dependence,ddparameter,hybrid_fitness,larval_weekly_survival,b(i),T,L,dev_dist,init_pop,tmax,niche_shift(j));
        eval(['hx' int2str(i) int2str(j) '=x;']);
        eval(['hy' int2str(i) int2str(j) '=y;']);
        eval(['hz' int2str(i) int2str(j) '=z;']);

    end
end

save('DataFigS4andS6_abc_variables.mat')


clear;
gridaccuracy=31;
dominance="S";
clutch_size_max=[100 100 100 100];
larval_weekly_survival=0.85;
T=0.25; 
L=1; 
dev_dist="dev_unif";
init_pop=10000;
tmax=44;
ddparameter=[1e-8*1 1e-8 1e-8]; 
hybrid_fitness=1 ;% Only difference among the 3 files producing fig S1 and fig S2

density_dependence="A";
niche_shift=[4 6];
b=[0.1 1 NaN]; 

figure(1); clf;
columns=length(niche_shift);
rows=length(b);
subplotno=0;

for i=1:rows
    for j=1:columns
        subplotno=subplotno+1;
        [i j]
        gridaccuracy=31;
        [x,y,z]=computetriangle(gridaccuracy,dominance,clutch_size_max,density_dependence,ddparameter,hybrid_fitness,larval_weekly_survival,b(i),T,L,dev_dist,init_pop,tmax,niche_shift(j));
        eval(['x' int2str(i) int2str(j) '=x;']);
        eval(['y' int2str(i) int2str(j) '=y;']);
        eval(['z' int2str(i) int2str(j) '=z;']);
            subplotno=subplotno+1;
            
        gridaccuracy=31*3;
        [x,y,z]=computetriangle(gridaccuracy,dominance,clutch_size_max,density_dependence,ddparameter,hybrid_fitness,larval_weekly_survival,b(i),T,L,dev_dist,init_pop,tmax,niche_shift(j));
        eval(['hx' int2str(i) int2str(j) '=x;']);
        eval(['hy' int2str(i) int2str(j) '=y;']);
        eval(['hz' int2str(i) int2str(j) '=z;']);

    end
end

save('DataFigS4andS6_def_variables.mat')

clear;
gridaccuracy=31;
dominance="S";
clutch_size_max=[100 100 100 100];
larval_weekly_survival=0.85;
T=0.25; 
L=1; 
dev_dist="dev_unif";
init_pop=10000;
tmax=44;
ddparameter=[1e-8*1 1e-8 1e-8]; 
hybrid_fitness=.5 ;% Only difference among the 3 files producing fig S1 and fig S2

density_dependence="A";
niche_shift=[4 6];
b=[0.1 1 NaN]; 

figure(1); clf;
columns=length(niche_shift);
rows=length(b);
subplotno=0;

for i=1:rows
    for j=1:columns
        subplotno=subplotno+1;
        [i j]
        gridaccuracy=31;
        [x,y,z]=computetriangle(gridaccuracy,dominance,clutch_size_max,density_dependence,ddparameter,hybrid_fitness,larval_weekly_survival,b(i),T,L,dev_dist,init_pop,tmax,niche_shift(j));
        eval(['x' int2str(i) int2str(j) '=x;']);
        eval(['y' int2str(i) int2str(j) '=y;']);
        eval(['z' int2str(i) int2str(j) '=z;']);
            subplotno=subplotno+1;
            
        gridaccuracy=31*3;
        [x,y,z]=computetriangle(gridaccuracy,dominance,clutch_size_max,density_dependence,ddparameter,hybrid_fitness,larval_weekly_survival,b(i),T,L,dev_dist,init_pop,tmax,niche_shift(j));
        eval(['hx' int2str(i) int2str(j) '=x;']);
        eval(['hy' int2str(i) int2str(j) '=y;']);
        eval(['hz' int2str(i) int2str(j) '=z;']);

    end
end

save('DataFigS4andS6_ghi_variables.mat')