% ___ compute :   "Sub-Indices"  via " Extracting  Elements "  +  Plotting 2 Y-Axes ____

clear all; close all; clf

fprintf(1, '\n')   
disp(['°°°°°°°°°°°°° S T A R T °°°°°°°°°°°° ' ,date, ' °°°°°°°°°°°°°°'])

t = 0 : pi/20 : 2*pi;
y = exp(sin(t));
n = length(t);
% ::::::::::::::::::::::::: extracting selected elements :::::::::::::::::::
% cut1 = t(2*end/3);                     % >> 1. Fehler 
CL = 0.95;
cl95 = round(n* CL);                    % > the 95% entity in the data
cut2 = t(cl95);

IDX = t(1:2*end/3);
Y = exp(sin(IDX));

P1 = [0.15,  0.25, 0.75,  0.7];           % Position des Hauptplots
P2 = [0.15,  0.15, 0.75,  0.05];          % Position der COLORBAR

figure(1)
ax1 = axes('Position',P1);               

    HP = plot(t,y,'r', 'Linewidth', 1.5);
    hold on
    S= stem(IDX, Y);
    set(S, 'Color', 'b' , 'Linewidth', 1)
% >>> 2. Fehler , wenn cut2  anstelle [2*end/3]  eingesetzt wird
    hg = area(t(2*end/3:end), y(2*end/3:end), 'Facecolor', 'g');   % > change in : cut2
    set(gca,'XTickLabel',[],'XLim',[t(1) t(end)]);         

% ::::::::::::::::::::::::::::::::::: COLORBAR ::::::::::::::::::::::::::
ax2 = axes('Position',P2);
M1 = colormap(winter(2));
cb = colorbar('horiz')
set(cb, 'Position',P2, 'Xtick', [], 'Ytick', [], 'Xticklabel', []);
                    
 set([ax1,ax2],'XLim',[min(t),max(t)]);

  % _____ TEXT  Labels  for Colorbar ____
  
xtick = get(ax2,'XTick');
xdazwischen = xtick/3;
ylim = get(ax2,'YLim');
yoben = ylim(2);
yunten = ylim(1);
ymitte = (yoben+yunten)/2;
textmitte = {'Hypothese HO','Hypothese HA'};

htmitte = text(xdazwischen, ymitte*ones(size(xdazwischen)),textmitte,...
    'HorizontalAlignment','center','VerticalAlignment','middle','fontweight','bold');

% ___________DATUM_________________________________
ax4 = axes('Position',[0.02,0.03,0.001,0.001],'Color','none','YColor','w');
printdate2 = ['printed on : ', datestr(now, 22), '.'];
printdate3 = {'U W E - Testplot', printdate2};
text(-0.2, -0.08, printdate3, 'units', 'normalized',   'fontangle', 'italic', 'fontsize', 8);

