Full Cycle

8
%NAME-Bhamare Kishor D. %MIS No.141305012 %Batch:-D %Program for Full Cycle Phase and Magnitude Estimation 1) Estimation of Voltage and Phase in Normal Condition clc; clear all; Vm=input('Enter Max magnitude='); f=input('Enter frequency='); p=input('Enter phase='); k=input('Enter number of samples='); VM=zeros(1,k); phase=zeros(1,k); t=0; d=(0.02/k); w=2*pi*f; for i=1:k; V(i)=Vm*sin(w*t+p); t=t+d; end; for z=1:k a=0; b=0; for j=1:k; theta=(j-1)*((2*pi)/k); a=a+(V(1,j)*sin(theta)); b=b+(V(1,j)*cos(theta)); end a=a*(2/k); b=b*(2/k); VM(1,z)=(a/cos(p)); phase(1,z)=asin(b/VM(1,z)); t=t+d; end; disp('The mean of magnitude is: '); g=mean(VM) disp('The mean of phase is: '); p=mean(phase) disp('The variance of magnitude is: '); v=var(VM) disp('The variance of phase is: ');

description

full cycle

Transcript of Full Cycle

Page 1: Full Cycle

%NAME-Bhamare Kishor D.%MIS No.141305012%Batch:-D%Program for Full Cycle Phase and Magnitude Estimation

1) Estimation of Voltage and Phase in Normal Condition

clc;clear all;Vm=input('Enter Max magnitude=');f=input('Enter frequency=');p=input('Enter phase=');k=input('Enter number of samples=');VM=zeros(1,k);phase=zeros(1,k);t=0; d=(0.02/k);w=2*pi*f;for i=1:k;V(i)=Vm*sin(w*t+p);t=t+d;end;for z=1:ka=0;b=0;for j=1:k; theta=(j-1)*((2*pi)/k); a=a+(V(1,j)*sin(theta)); b=b+(V(1,j)*cos(theta));end a=a*(2/k);b=b*(2/k);VM(1,z)=(a/cos(p));phase(1,z)=asin(b/VM(1,z));t=t+d;end;disp('The mean of magnitude is: ');g=mean(VM)disp('The mean of phase is: ');p=mean(phase)disp('The variance of magnitude is: ');v=var(VM)disp('The variance of phase is: ');p1=var(phase)t=1:1:k;plot(t,g);xlabel('Sample Number(N)');ylabel('Estimated Value (Vm)'

Page 2: Full Cycle

Results:-

The mean of magnitude is:

g =

10.0000

The mean of phase is:

p =

0.5230

The variance of magnitude is:

v =

3.0957e-26

The variance of phase is:

p1 =

7.1266e-29

Page 3: Full Cycle

2) Estimation of Voltage and Phase in the Presence of DC Offset clcVm=input('Enter Max magnitude=');f=input('Enter frequency=');p=input('Enter phase=');k=input('Enter number of samples=');E=input('Enter randn multiplier=');VM=zeros(1,k);phase=zeros(1,k);t=0; d=(0.02/k);for i=1:k;V(i)=Vm*sin(w*t+p)+E*randn();t=t+d;end;for z=1:kw=2*pi*f;a=0;b=0; for j=1:k; theta=(j-1)*((2*pi)/k); a=a+(V(1,j)*sin(theta)); b=b+(V(1,j)*cos(theta));end a=a*(2/k);b=b*(2/k);VM(1,z)=(a/cos(p));phase(1,z)=asin(b/VM(1,z));t=t+d;end;disp('The mean of magnitude is: ');g=mean(VM)disp('The mean of phase is: ');p=mean(phase)disp('The variance of magnitude is: ');v=var(VM)disp('The variance of phase is: ');p1=var(phase)t=1:1:k;plot(t,g);xlabel('Sample Number(N)');ylabel('Estimated Value (Vm)');

Results:-

Page 4: Full Cycle

Enter Max magnitude=10

Enter frequency=50

Enter phase=0.523

Enter number of samples=1000

Enter randn multiplier=3

The mean of magnitude is:

g =

9.8314

The mean of phase is:

p =

0.5434

The variance of magnitude is:

v =

4.7786e-26

The variance of phase is:

p1 =

3.5658e-30

Page 5: Full Cycle

Values of Estimated voltage and Phase for Different randan Multiplier Coefficients

Multiplier of E(randan) Mean of Magnitude Mean of Phase Variance of Magnitude Variance of Phase0.1 10.003 0.5223 3.8459e-26 4.4418e-310.4 9.9116 0.5223 2.9110e-26 2.0852e-300.9 10.021 0.5227 2.0215e-26 4.4118e-301.3 10.006 0.5182 8.8725e-27 1.9741e-292 9.9277 0.5239 4.5484e-28 9.7732e-292.5 9.8812 0.5279 9.9054e-27 2.4985e-293 10.184 0.5151 1.4605e-26 6.3962e-29

Page 6: Full Cycle

3) Estimation of Phase and Voltage in Presence of DC offset

%NAME-Bhamare Kishor D.%MIS No.141305012%Batch:-Dclc;clear all;Vm=input('Enter Max magnitude=');f=input('Enter frequency=');p=input('Enter phase=');k=input('Enter number of samples=');VM=zeros(1,k);phase=zeros(1,k);t=0;w=2*pi*f;d=(0.02/k);for j=1:k;V(j)=Vm*sin(w*t+p)+5*exp(-5i*w*j);t=t+d;end;for z=1:ka=0;b=0;for j=1:k; theta=(j-1)*((2*pi)/k); a=a+(V(1,j)*sin(theta)); b=b+(V(1,j)*cos(theta));end a=a*(2/k);b=b*(2/k);VM(1,z)=(a/cos(p));phase(1,z)=asin(b/VM(1,z));t=t+d;end;disp('The mean of magnitude is: ');g=mean(VM)disp('The mean of phase is: ');p=mean(phase)disp('The variance of magnitude is: ');v=var(VM)disp('The variance of phase is: ');p1=var(phase)t=1:1:k;plot(t,g);xlabel('Sample Number(N)');ylabel('Estimated Value (Vm)');

Page 7: Full Cycle

Results:-

Enter Max magnitude=10

Enter frequency=50

Enter phase=0.523

Enter number of samples=1000

The mean of magnitude is:

g =

10.0000 + 0.0000i

The mean of phase is:

p =

0.5230 - 0.0000i

The variance of magnitude is:

v =

2.7909e-26

The variance of phase is:

p1 =

6.5751e-29