1 | function [Xmean Zmean] = getmeanorbit(varargin) |
---|
2 | % GETMEANORBIT - Compute mean orbit using turn by turn data |
---|
3 | % |
---|
4 | % INPUTS |
---|
5 | % 1. |
---|
6 | % |
---|
7 | % OUPUTS |
---|
8 | % 1. Xmean - Mean horizontal orbit |
---|
9 | % 2. Z mean - Mean vertical orbit |
---|
10 | % |
---|
11 | |
---|
12 | % |
---|
13 | % Written by Laurent S. Nadolski |
---|
14 | |
---|
15 | DisplayFlag = 1; |
---|
16 | |
---|
17 | % Option parser |
---|
18 | for i = length(varargin):-1:1 |
---|
19 | if strcmpi(varargin{i},'Display') |
---|
20 | DisplayFlag = 1; |
---|
21 | varargin(i) = []; |
---|
22 | elseif strcmpi(varargin{i},'NoDisplay') |
---|
23 | DisplayFlag = 0; |
---|
24 | varargin(i) = []; |
---|
25 | end |
---|
26 | end |
---|
27 | |
---|
28 | |
---|
29 | istart = 27; % depart lecture BPM |
---|
30 | iend = 400; % fin lecture BPM |
---|
31 | |
---|
32 | bpmdata = getbpmrawdata([],'nodisplay','struct'); |
---|
33 | |
---|
34 | Xmean = mean(bpmdata.Data.X(:,istart:iend)'); |
---|
35 | Zmean = mean(bpmdata.Data.Z(:,istart:iend)'); |
---|
36 | |
---|
37 | if DisplayFlag |
---|
38 | figure(103); |
---|
39 | posvect = getspos('BPMx'); |
---|
40 | h1 = subplot(7,1,[1 3]); |
---|
41 | plot(posvect, Xmean,'r.-'); |
---|
42 | grid on |
---|
43 | ylabel('X (mm)'); |
---|
44 | axis([0 getcircumference -11 11]); |
---|
45 | title(['Mean orbit between ' num2str(istart) ' and ' num2str(iend) ' turns']); |
---|
46 | ylim([-5 5]) |
---|
47 | |
---|
48 | h2 = subplot(7,1,4); |
---|
49 | drawlattice; hold on; |
---|
50 | set(h2,'XTick',[],'YTick',[]); |
---|
51 | |
---|
52 | h3 = subplot(7,1,[5 7]); |
---|
53 | plot(posvect, Zmean,'b.-'); |
---|
54 | grid on |
---|
55 | xlabel('s (mm)') |
---|
56 | ylabel('Z (mm)'); |
---|
57 | ylim([-5 5]) |
---|
58 | |
---|
59 | % links axes |
---|
60 | linkaxes([h1 h2 h3],'x'); |
---|
61 | end |
---|