clear all
close all

%Plot the maximum currents, voltages and powers vs conduction angle.

Vcc = 5;
P = 1;

alpha = linspace(.01,2*pi,100);

Imax = 4*P/Vcc; %Imax has this value for class A and it must old up in the saturation modes

Idc = (Imax/2/pi)*(2*sin(alpha/2) - alpha.*cos(alpha/2))./(1 - cos(alpha/2));

I1 = (Imax/2/pi)*(alpha - sin(alpha))./(1 - cos(alpha/2));

Vs = 2*P./I1;
%Cripps does this

Vs = Vcc;

Rload = Vs./I1;

Pdis = Vcc*Idc - Vs.*I1/2;

F1 = 2*sin(alpha/2) - alpha.*cos(alpha/2);
F2 = alpha - sin(alpha);

Pdis = Vcc*F1 - Vs.*F2/2;
Pdis = Imax*Pdis./(1 - cos(alpha/2))./alpha;

%eta = P/Vcc./Idc;

Pout = .5*Vs.*I1;
eta = Pout/Vcc./Idc;
figure(1)
plot(alpha,eta,alpha,Pdis,'r',alpha,log10(Rload),'k',alpha,Pout,'g','LineWidth',3)
title('eta, Pdis, Optimal Rload vs alpha') 
axis([0 2*pi 0 3])

break
igure(2)
subplot(2,1,1)
plot(alpha/pi, 10*log10(Pout/P),'LineWidth',3)
axis([0 2 -5 5])

subplot(2,1,2)
plot(alpha/pi, 100*eta,'LineWidth',3)
axis([0 2 0 100])
