Current

PURPOSE ^

Current Supplies some current patterns for 2D EIT

SYNOPSIS ^

function [I,T]=Current(L,lg,style,rms,numpat);

DESCRIPTION ^

Current Supplies some current patterns for 2D EIT
 Function [I,T]=Current(L,lg,style,rms,numpat) calculates 
 different current patterns. The 'style' can be 'tri' (trigonometric), 
 'adj' (adjacent), 'opp' (opposite) or 'ref' (one reference). 

 INPUT

 L = the number of electrodes
 lg = the number of nodes
 style = 'tri' (trigonometric), 'adj' (adjacent), 'opp' (opposite) or 'ref' (one reference)
 rms = the root mean square value of the injected current. Default=1 (optional).
 numpat = the number of patterns (optional, in certain cases forced to be L-1)

 OUTPUT

 I = the total current matrix, internal and on the electrodes 
 T = currents on the electrodes

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [I,T]=Current(L,lg,style,rms,numpat);
0002 
0003 %Current Supplies some current patterns for 2D EIT
0004 % Function [I,T]=Current(L,lg,style,rms,numpat) calculates
0005 % different current patterns. The 'style' can be 'tri' (trigonometric),
0006 % 'adj' (adjacent), 'opp' (opposite) or 'ref' (one reference).
0007 %
0008 % INPUT
0009 %
0010 % L = the number of electrodes
0011 % lg = the number of nodes
0012 % style = 'tri' (trigonometric), 'adj' (adjacent), 'opp' (opposite) or 'ref' (one reference)
0013 % rms = the root mean square value of the injected current. Default=1 (optional).
0014 % numpat = the number of patterns (optional, in certain cases forced to be L-1)
0015 %
0016 % OUTPUT
0017 %
0018 % I = the total current matrix, internal and on the electrodes
0019 % T = currents on the electrodes
0020 
0021 % M. Vauhkonen 6.9.1994. Modified 13.9.1994 for NOSER.
0022 % Modified 13.8.1999 by M. Vauhkonen,
0023 % University of Kuopio, Department of Applied Physics, PO Box 1627,
0024 % FIN-70211 Kuopio, Finland, email: Marko.Vauhkonen@uku.fi
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]];% Optional!!
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 %II=[II(:,1:ceil(numpat/2)),-II(:,1:floor(numpat/2))];% Optional!!
0103 I=[zeros(lg,numpat);rms*II];
0104 T=II;
0105 end
0106 
0107 
0108 
0109 
0110 
0111 
0112 
0113 
0114 
0115 
0116

Generated on Tue 09-Aug-2011 11:38:31 by m2html © 2005