0001 function P = mkparamgroup(LATTICE,varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 if isnumeric(varargin{1})
0018 if ~((nargin==3)& ischar(varargin{2}))
0019 error('The third argument must be a string')
0020 else
0021 INDEX = varargin{1};
0022 KIDNUM = 1:length(INDEX);
0023 PARAMSTR = varargin{2};
0024 end
0025 else
0026 FAMNAMESTR = varargin{1};
0027 INDEX = findcells(LATTICE,'FamName',FAMNAMESTR);
0028 if(isempty(INDEX))
0029 error(['No elements that belong to the family ''',FAMNAMESTR,...
0030 ''' found in the lattice ',inputname(1)]);
0031 end
0032 if isnumeric(varargin{2})
0033 KIDNUM = varargin{2};
0034 PARAMSTR = varargin{3};
0035 else
0036 KIDNUM = 1:length(INDEX);
0037 PARAMSTR = varargin{2};
0038 end
0039 end
0040
0041 switch lower(PARAMSTR)
0042 case {'k1','k'}
0043 if ~isfield(LATTICE{INDEX(KIDNUM(1))},'K')
0044 error('Element ',int2str(KIDNUM(i)),' does not have field ''K''');
0045 end
0046 P1 = struct('ElemIndex',num2cell(INDEX(KIDNUM)),'FieldName','K','Function',inline('x'));
0047 [P1.FieldIndex]=deal({1,1});
0048 [P1.Args]=deal({});
0049
0050 if ~isfield(LATTICE{INDEX(KIDNUM(1))},'PolynomB')
0051 error('Element ',int2str(KIDNUM(1)),' does not have field ''PolynomB''');
0052 end
0053 P2 = struct('ElemIndex',num2cell(INDEX(KIDNUM)),'FieldName','PolynomB','Function',inline('x'));
0054 [P2.FieldIndex]=deal({1,2});
0055 [P2.Args]=deal({});
0056
0057 for k = 1:length(KIDNUM)
0058 P1(k).SavedValue = LATTICE{INDEX(KIDNUM(k))}.K;
0059 P2(k).SavedValue = LATTICE{INDEX(KIDNUM(k))}.PolynomB(2);
0060 end
0061 P = reshape([P1;P2],1,2*length(P1));
0062 case 'k2'
0063
0064 if ~isfield(LATTICE{INDEX(KIDNUM(1))},'PolynomB')
0065 error('Element ',int2str(KIDNUM(1)),' does not have field ''PolynomB''');
0066 end
0067 P = struct('ElemIndex',num2cell(INDEX(KIDNUM)),'FieldName','PolynomB','Function',inline('x'));
0068 [P.FieldIndex]=deal({1,3});
0069 [P.Args]=deal({});
0070 for k = 1:length(KIDNUM)
0071 P(k).SavedValue = LATTICE{INDEX(KIDNUM(k))}.PolynomB(3);
0072 end
0073 case 'k3'
0074 if ~isfield(LATTICE{INDEX(KIDNUM(1))},'PolynomB')
0075 error('Element ',int2str(KIDNUM(1)),' does not have field ''PolynomB''');
0076 end
0077 P = struct('ElemIndex',num2cell(INDEX(KIDNUM)),'FieldName','PolynomB','Function',inline('x'));
0078 [P.FieldIndex]=deal({1,4});
0079 [P.Args]=deal({});
0080 for k = 1:length(KIDNUM)
0081 P(k).SavedValue = LATTICE{INDEX(KIDNUM(k))}.PolynomB(4);
0082 end
0083
0084 case 'tilt'
0085 if ~isfield(LATTICE{INDEX(KIDNUM(1))},'R1')
0086 error('Element ',int2str(KIDNUM(1)),' does not have field ''R1''');
0087 end
0088 if ~isfield(LATTICE{INDEX(KIDNUM(1))},'R2')
0089 error('Element ',int2str(KIDNUM(1)),' does not have field ''R2''');
0090 end
0091
0092 P1 = struct('ElemIndex',num2cell(INDEX(KIDNUM)),'FieldName','R1','Function',inline('mksrollmat(x)'));
0093 [P1.FieldIndex]=deal({1:6,1:6});
0094 [P1.Args]=deal({});
0095
0096 P2 = struct('ElemIndex',num2cell(INDEX(KIDNUM)),'FieldName','R2','Function',inline('mksrollmat(-x)'));
0097 [P2.FieldIndex]=deal({1:6,1:6});
0098 [P2.Args]=deal({});
0099
0100 for k = 1:length(KIDNUM)
0101 P1(k).SavedValue = LATTICE{INDEX(KIDNUM(k))}.R1;
0102 P2(k).SavedValue = LATTICE{INDEX(KIDNUM(k))}.R2;
0103 end
0104 P = reshape([P1;P2],1,2*length(P1));
0105
0106 case {'k1','k'}
0107 if ~isfield(LATTICE{INDEX(KIDNUM(1))},'K')
0108 error('Element ',int2str(KIDNUM(k)),' does not have field ''K''');
0109 end
0110
0111 P1 = struct('ElemIndex',num2cell(INDEX(KIDNUM)),'FieldName','K','Function',inline('x'));
0112 [P1.FieldIndex]=deal({1,1});
0113 [P1.Args]=deal({});
0114
0115 if ~isfield(LATTICE{INDEX(KIDNUM(1))},'PolynomB')
0116 error('Element ',int2str(KIDNUM(1)),' does not have field ''PolynomB''');
0117 end
0118 P2 = struct('ElemIndex',num2cell(INDEX(KIDNUM)),'FieldName','PolynomB','Function',inline('x'));
0119 [P2.FieldIndex]=deal({1,2});
0120 [P2.Args]=deal({});
0121
0122 for k = 1:length(KIDNUM)
0123 P1(k).SavedValue = LATTICE{INDEX(KIDNUM(k))}.K;
0124 P2(k).SavedValue = LATTICE{INDEX(KIDNUM(k))}.PolynomB(2);
0125 end
0126 P = reshape([P1;P2],1,2*length(P1));
0127
0128 case {'s','s1'}
0129 if ~isfield(LATTICE{INDEX(KIDNUM(1))},'PolynomA')
0130 error('Element ',int2str(KIDNUM(1)),' does not have field ''PolynomA''');
0131 end
0132 P = struct('ElemIndex',num2cell(INDEX(KIDNUM)),'FieldName','PolynomA','Function',inline('x'));
0133 [P.FieldIndex]=deal({1,2});
0134 [P.Args]=deal({});
0135 for k = 1:length(KIDNUM)
0136 P(k).SavedValue = LATTICE{INDEX(KIDNUM(k))}.PolynomA(2);
0137 end
0138
0139 end
0140