Home > pubtools > LatticeTuningFunctions > errors > bpm_matrices.m

bpm_matrices

PURPOSE ^

BPM_MATRICES Computes the transformation matrices for the given BPMs

SYNOPSIS ^

function [rel,tel,trand] = bpm_matrices(bpms)

DESCRIPTION ^

BPM_MATRICES Computes the transformation matrices for the given BPMs

   [R,T,TRAND]=BPM_MATRICES(BPMS)

 by L.F. Jun 2016, ESRF,  K:\machine\matlab\atlf

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [rel,tel,trand] = bpm_matrices(bpms)
0002 %BPM_MATRICES Computes the transformation matrices for the given BPMs
0003 %
0004 %   [R,T,TRAND]=BPM_MATRICES(BPMS)
0005 %
0006 % by L.F. Jun 2016, ESRF,  K:\machine\matlab\atlf
0007 
0008 
0009 [rel,tel,trand]=cellfun(@extract,bpms','UniformOutput',false);
0010 
0011     function [rel,tel,trand]=extract(el)
0012         if isfield(el,'R1')
0013             r1=el.R1([1 3],[1 3]);
0014         else
0015             r1=eye(2);
0016         end
0017         if isfield(el,'T1')
0018             t1=el.T1([1 3]);
0019         else
0020             t1=[0;0];
0021         end
0022         if isfield(el,'Offset')
0023             tb=el.Offset(:);
0024         else
0025             tb=[0;0];
0026         end
0027         if isfield(el,'Rotation')
0028             C=cos(el.Rotation(1));
0029             S=sin(el.Rotation(1));
0030             rb=[C S;-S C];
0031         else
0032             rb=eye(2);
0033         end
0034         if isfield(el,'Scale')
0035             scale=el.Scale(:);
0036         else
0037             scale=[1;1];
0038         end
0039         if isfield(el,'Reading')
0040             trand=el.Reading(:);
0041         else
0042             trand=[0;0];
0043         end
0044         tel=scale.*(rb*r1*t1+tb);
0045         rel=[scale scale].*(rb*r1);
0046     end
0047 end

Generated on Thu 24-Aug-2017 18:47:33 by m2html © 2005