function asmb = linarray (modelFreq, obj, editParms) %------------------------------------------------------------------------- % THE FIRST PART OF THIS FILE IS COMPUTER GENERATED - DO NOT EDIT IT !!! % PAGE DOWN TO THE USER DEFINED SECTION WHICH STARTS WITH THE SEGMENT % ROUTINE. %------------------------------------------------------------------------- % USAGE: % asmb = linarray (modelFreq, obj, editParms) % DESCRIPTION: % Linear Array Assembly % INPUTS: % modelFreq: The frequency at which the SNEC structure is designed % obj.location: The location of the assembly % obj.segLength: The segment length in wavelengths % obj.orientation: The orientation of the assembly % obj.freqScale: The factor by which the model freq. is scaled % obj.end1: end1 % obj.end2: end2 % obj.radius: radius % obj.voltages: feed voltages % obj.noOfSegs: no segs (0=auto) % obj.translation: spacing % obj.thetaoff: steering angle deg % % OUTPUTS: % struct assembly % { % name // the name of the assembly % properties // array of structs % segments // cell array of startPt, endPt, radius % plates // cell array of plate data % cylinders // cell array of cylinder data % assemblies // cell array of structs like this % } if (nargin < 1) ErrorDlg ('You must specify the model freq when calling linarray','linarray Usage Error'); asmb = []; return; end switch nargin case 1 obj.location = [0.000, 0.000, 0.000]; obj.segLength = 0.100; obj.orientation = [0.000, 0.000, 0.000]; obj.freqScale = 1.000; obj.end1 = [-0.250, 0.000, 0.000]; obj.end2 = [0.250, 0.000, 0.000]; obj.radius = 0.001; obj.voltages = 1.000; obj.noOfSegs = 0.000; obj.translation = [0.000, 0.000, 1.000]; obj.thetaoff = 0.000; editParms = 1; case 2 editParms = 1; case 3 % do nothing otherwise asmb = []; ErrorDlg ('Invalid number of inputs to linarray','linarray Usage Error'); return; end commonStruct = struct(... 'prompt',{'Location';'Segment Length';'Orientation';'Freq. Scaling'}, ... 'value',{obj.location; obj.segLength; obj.orientation; obj.freqScale}, ... 'type',{'real';'real';'real';'real'}, ... 'length',{3; 1; 3; 1}, ... 'range',{[]; [0.001 0.5]; [0 360]; [1E-5 inf]}); dlgStruct = struct(... 'prompt', {... 'end1', ... 'end2', ... 'radius', ... 'feed voltages', ... 'no segs (0=auto)', ... 'spacing', ... 'steering angle deg'}, ... 'value', {obj.end1, obj.end2, obj.radius, obj.voltages, obj.noOfSegs, obj.translation, obj.thetaoff}, ... 'noOfCols', {3, 3, 1, [], 1, 3, 1}, ... 'noOfRows', {1, 1, 1, 1, 1, 1, 1}, ... 'range', {[ -inf inf ], [ -inf inf ], [ -inf inf ], [ -inf inf ], [ -inf inf ], [ -inf inf ], [ -inf inf ]}, ... 'type', {'real', 'real', 'real', 'real', 'real', 'real', 'real'}, ... 'help', {... 'end1', ... 'end2', ... 'radius', ... 'feed voltages', ... 'no segs (0=auto)', ... 'spacing', ... 'steering angle deg'}); obj.type = 'linarray'; obj.commonStruc = commonStruct; obj.dlgStruc = dlgStruct; if (editParms) [obj,okay] = snasmbdlg (obj); else okay = 1; end if (okay) location = obj.commonStruc(1).value; segLength = obj.commonStruc(2).value; orientation = obj.commonStruc(3).value; freqScale = obj.commonStruc(4).value; end1 = obj.dlgStruc(1).value; end2 = obj.dlgStruc(2).value; radius = obj.dlgStruc(3).value; voltages = obj.dlgStruc(4).value; noOfSegs = obj.dlgStruc(5).value; translation = obj.dlgStruc(6).value; thetaoff = obj.dlgStruc(7).value; asmb = Segment (modelFreq, location, segLength, orientation, freqScale, end1, end2, radius, voltages, noOfSegs, translation, thetaoff); asmb.name = 'linarray'; asmb.properties = struct ('name',{ 'location', 'segLength', 'orientation', 'freqScale', 'end1', 'end2', 'radius', 'voltages', 'noOfSegs', 'translation', 'thetaoff'}, ... 'value',{ location, segLength, orientation, freqScale, end1, end2, radius, voltages, noOfSegs, translation, thetaoff}); else asmb = []; end %------------------------------------------------------------------------- % WRITE YOUR SEGMENT ROUTINE AFTER THE LINE: freqMHz = modelFreq.*freqScale; %------------------------------------------------------------------------- function asmb = Segment (modelFreq, ... location, ... segLength, ... orientation, ... freqScale, ... end1, ... end2, ... radius, ... voltages, ... noOfSegs, ... translation, ... thetaoff) freqMHz = modelFreq.*freqScale; asmb.name = 'linarray'; obj1.segLength = segLength; obj1.orientation = orientation; obj1.freqScale = freqScale; obj1.end1 = end1; obj1.end2 = end2; obj1.radius = radius; obj1.noOfSegs = noOfSegs; freqMHz1 = modelFreq.*freqScale; % ASSEMBLY CODE TO MAKE A LINEAR ARRAY Augustin del Alamo Feb. 8, 2006 lambda = 299.8/freqMHz1; K=2*pi/lambda; D=norm(end1-end2); Tr=norm(translation); n=length(voltages); for k=1:n obj1.location = location + (k-1)*translation; %error in original code obj1.voltage = voltages(k)*exp(i*K*D*sin(thetaoff/180*pi)*(k-1)); obj1.voltage = voltages(k)*exp(i*K*Tr*sin(thetaoff/180*pi)*(k-1)); asmb.assemblies{k} = sndipole(modelFreq, obj1, 0); end