0001 function [I,T]=Current(L,lg,style,rms,numpat);
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027 if nargin < 4 & style == 'tri'
0028 rms=1;
0029 numpat=L-1;
0030 end
0031
0032 if nargin < 4 & style ~= 'tri'
0033 rms=1;
0034 numpat=L;
0035 end
0036
0037 if nargin == 4 & style == 'tri'
0038 numpat=L-1;
0039 end
0040
0041 if nargin == 4 & style ~= 'tri'
0042 numpat=L;
0043 end
0044
0045
0046 switch style
0047 case 'tri'
0048 if numpat > L-1,
0049 str=['Too many current patterns. Automatically set to ', num2str(L-1),'.' ];
0050 disp(str)
0051 numpat =L-1;
0052 end
0053 II=zeros(L,numpat);
0054 l=(1:L)';
0055 th=2*pi*l/L;
0056 for k=1:(numpat+1)/2,
0057 II(:,k)=rms*cos(k*th);
0058 end
0059 for k=(numpat+1)/2+1:numpat
0060 II(:,k)=rms*sin((k-L/2)*th);
0061 end
0062 I=[zeros(lg,numpat);II];
0063 T=II;
0064
0065 case 'adj'
0066 II=zeros(L,numpat);
0067 l=(1:L)';
0068 II1=diag(ones(L,1));
0069 II2=diag(ones(L-1,1),-1);
0070 if numpat < L
0071 II=II1(:,1:numpat)-II2(:,1:numpat);
0072 else
0073 II=II1(:,1:numpat-1)-II2(:,1:numpat-1);
0074 II=[II,[-1;zeros(L-2,1);1]];
0075 end
0076 I=[zeros(lg,numpat);rms*II];
0077 T=II;
0078
0079 case 'ref'
0080 if numpat > L-1,
0081 str=['Too many current patterns. Automatically set to ', num2str(L-1),'.' ];
0082 disp(str)
0083 numpat =L-1;
0084 end
0085 II=zeros(L,numpat);
0086 II1=diag(ones(L-1,1),-1);
0087 II(1,:)=ones(1,numpat);
0088 T=II-II1(:,1:numpat);
0089 I=[zeros(lg,numpat);rms*T];
0090
0091
0092 case 'opp'
0093 if numpat > L/2,
0094 str=['Too many current patterns. Automatically set to ', num2str(L/2),'.' ];
0095 disp(str)
0096 numpat=L/2;end
0097 II=zeros(L,numpat);
0098 l=(1:L)';
0099 II1=diag(ones(L,1));
0100 II2=diag(ones(L,1),-L/2);
0101 II=II1(:,1:numpat)-II2(1:L,1:numpat);
0102
0103 I=[zeros(lg,numpat);rms*II];
0104 T=II;
0105 end
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116