%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                              Example 3.6                                %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                         %
%                         Current Mirror Mismatch                         %
%                                                                         %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

clear all;

%-------------------------------------------------------------------------%
%                                                                         %
%                                Input data                               %
%                                                                         %
%-------------------------------------------------------------------------%

Abeta=0.003;
AVT=0.002;
DI_I=0.003;
Vov=0.4;

%-------------------------------------------------------------------------%
%                                                                         %
%                               Calculate WL                              %
%                                                                         %
%-------------------------------------------------------------------------%


WLnom=(Abeta^2+4*AVT^2/Vov^2)/DI_I^2
W_L=ones(1,100);
for i=1:100,
    WL=WLnom/10*i;
    err=sqrt((Abeta^2+4*AVT^2/Vov^2)/WL);
    W_L(i)=WL/WLnom;
    DeltaI_I(i)=err*100;
end

%--------------------------------Graphic----------------------------------%
%                                                                         %
%     figure(1) --> Figure 3.37 page 121                                  %
%                                                                         %
%-------------------------------------------------------------------------%

figure(1)
semilogx(W_L,DeltaI_I,'r')
grid
xlabel('Scaling factor')
ylabel('\DeltaI/I [%]')
text(1,0.75,sprintf('\\bf\\DeltaI/I = %3.1f%% @  WL = %3.2f\\mu^2',DI_I*...
    100,WLnom),'Fontsize', 12, 'HorizontalAlignment', 'center');