source: MML/trunk/machine/SOLEIL/StorageRing/steerette/correction_tour1_singval_V.m @ 4

Last change on this file since 4 was 4, checked in by zhangj, 10 years ago

Initial import--MML version from SOLEIL@2013

File size: 13.8 KB
Line 
1function varargout = correction_tour1_singval_V(varargin)
2% CORRECTION_TOUR1_singval_V M-file for correction_tour1_singval_V.fig
3%      CORRECTION_TOUR1_singval_V, by itself, creates a new CORRECTION_TOUR1_singval_V or raises the existing
4%      singleton*.
5%
6%      H = CORRECTION_TOUR1_singval_V returns the handle to a new CORRECTION_TOUR1_singval_V or the handle to
7%      the existing singleton*.
8%
9%      CORRECTION_TOUR1_SINGVAL('CALLBACK',hObject,eventData,handles,...) calls the local
10%      function named CALLBACK in CORRECTION_TOUR1_SINGVAL.M with the given input arguments.
11%
12%      CORRECTION_TOUR1_SINGVAL('Property','Value',...) creates a new CORRECTION_TOUR1_singval_V or raises the
13%      existing singleton*.  Starting from the left, property value pairs are
14%      applied to the GUI before correction_tour1_singval_OpeningFunction gets called.  An
15%      unrecognized property name or invalid value makes property application
16%      stop.  All inputs are passed to correction_tour1_singval_OpeningFcn via varargin.
17%
18%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
19%      instance to run (singleton)".
20%
21% See also: GUIDE, GUIDATA, GUIHANDLES
22
23% Edit the above text to modify the response to help correction_tour1_singval
24
25% Last Modified by GUIDE v2.5 06-Apr-2006 13:54:43
26
27% Begin initialization code - DO NOT EDIT
28gui_Singleton = 1;
29gui_State = struct('gui_Name',       mfilename, ...
30                   'gui_Singleton',  gui_Singleton, ...
31                   'gui_OpeningFcn', @correction_tour1_singval_V_OpeningFcn, ...
32                   'gui_OutputFcn',  @correction_tour1_singval_V_OutputFcn, ...
33                   'gui_LayoutFcn',  [] , ...
34                   'gui_Callback',   []);
35if nargin && ischar(varargin{1})
36    gui_State.gui_Callback = str2func(varargin{1});
37end
38
39if nargout
40    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
41else
42    gui_mainfcn(gui_State, varargin{:});
43end
44% End initialization code - DO NOT EDIT
45
46% --- Executes just before correction_tour1_singval_V is made visible.
47function correction_tour1_singval_V_OpeningFcn(hObject, eventdata, handles, varargin)
48% This function has no output args, see OutputFcn.
49% hObject    handle to figure
50% eventdata  reserved - to be defined in a future version of MATLAB
51% handles    structure with handles and user data (see GUIDATA)
52% varargin   command line arguments to correction_tour1_singval_V (see VARARGIN)
53
54% Choose default command line output for correction_tour1_singval
55handles.output = hObject;
56if iscell(varargin) && ~isempty(varargin)
57   
58    % store handle from caller
59    handles.caller = varargin{1}.figure1;
60   
61    % Get values from Application-Defined data
62    %handles.energie_edit38=findobj(allchild(handles.caller3),...
63    %    'Tag','energie_edit38');
64    handles.nb_correcteurs_V_edit = findobj(allchild(handles.caller),...
65        'Tag','nb_correcteurs_V_edit');
66   
67   
68    % matrice singular values
69    S_V = getappdata(handles.caller,'S_V');
70    V = diag(S_V);
71   
72    % initalisation popupmenu
73    set(handles.val_sing_V_popupmenu, 'String',...
74        {'liste valeurs singulières', V(:)});
75        %{'liste valeurs singulières', sprintf('%3.2f',V(:))});
76   
77    % positionner le popup à la dernière valeur (on prend par défaut toutes
78    % les valeurs propres
79    set(handles.val_sing_V_popupmenu,'Value',size(S_V,2)+1);
80    setappdata(handles.caller,'valvp_V',size(S_V,2));
81    k = get(handles.val_sing_V_popupmenu,'Value') - 1;
82   
83    % plot des valeurs singulières
84    name=['axes' num2str(1)];
85    axes(handles.(name));
86    if size(S_V,2)==0
87        %disp('correction_tour1_singval_V');
88        xdata = 1;
89        V = [0];
90    else
91        xdata = 1:size(S_V,2);
92    end
93    plot(xdata,V,'rs-','Tag','line1');
94    hold on
95    set(handles.(name), 'YGrid','On');
96    set(handles.(name), 'XGrid','On');
97    set(gca, 'YMinorTick','On');
98    %set(handles.(name), 'XMinorTick','On');
99    xlabel(handles.(name),'no de la valeur singulière');
100    ylabel(handles.(name),'valeur singulière');
101    if size(S_V,2)>0
102        xlim([1 xdata(end)]);
103    else
104       
105    end
106   
107    % positionner le curseur à la valeur propre choisie
108    if k==0
109        k = 1
110    end
111    plot(k,V(k),'rp','MarkerEdgeColor','k',...
112                    'MarkerFaceColor','r',...
113                    'MarkerSize',14,'Tag','line2');
114    hold off
115end
116
117% Update handles structure
118guidata(hObject, handles);
119
120% This sets up the initial plot - only do when we are invisible
121% so window can get raised using correction_tour1_singval_V.
122%if strcmp(get(hObject,'Visible'),'off')
123%    plot(rand(5));
124%end
125
126% UIWAIT makes correction_tour1_singval_V wait for user response (see UIRESUME)
127% uiwait(handles.figure1);
128
129
130% --- Outputs from this function are returned to the command line.
131function varargout = correction_tour1_singval_V_OutputFcn(hObject, eventdata, handles)
132% varargout  cell array for returning output args (see VARARGOUT);
133% hObject    handle to figure
134% eventdata  reserved - to be defined in a future version of MATLAB
135% handles    structure with handles and user data (see GUIDATA)
136
137% Get default command line output from handles structure
138varargout{1} = handles.output;
139
140% --- Executes on button press in correction_tour1_singval_V.
141function rafraichir_V_pushbutton_Callback(hObject, eventdata, handles)
142% hObject    handle to correction_tour1_singval_V (see GCBO)
143% eventdata  reserved - to be defined in a future version of MATLAB
144% handles    structure with handles and user data (see GUIDATA)
145
146% axes(handles.axes1);
147% cla;
148
149% recalculer la matrice S_V
150
151% nbre de correcteurs utilisés dans la correction SVD
152nbcorrSVD_V = get(handles.nb_correcteurs_V_edit,'String');
153nbcorrSVD_V = str2num(nbcorrSVD_V);
154% correcteur actuellement selectionné
155valCV = getappdata(handles.caller,'n_selection_CV');
156%if isequal(valCV,0)|isequal(valCVV,1)
157if valCV<nbcorrSVD_V
158    errordlg('avancez à un nombre adéquat de correcteurs !','Attention');
159    % sortir de la fonction
160    return
161end
162Meff_V = getappdata(handles.caller,'Meff_V');
163BPMz = getappdata(handles.caller,'BPMz');
164VCOR = getappdata(handles.caller,'VCOR');
165% extraire la matrice
166flag = 0;
167liste_elem_BPM = [];
168for j = 1 : length(BPMz.Position)
169    if BPMz.Position(j)>VCOR.Position(valCV-nbcorrSVD_V+1) 
170        if BPMz.Position(j)>VCOR.Position(valCV+1)
171            break
172        end
173        flag = flag + 1;
174        liste_elem_BPM = [liste_elem_BPM j];
175        Meffloc_V(flag,:) = Meff_V(j,valCV-nbcorrSVD_V+1:valCV);
176    end
177end
178% nbBPM  = flag;
179% liste_dev_BPM = elem2dev('BPMx',liste_elem_BPM);
180% HCOR_liste = getappdata(handles.figure1,'HCOR_liste');
181% liste_dev_HCOR = HCOR_liste(valCH-nbcorrSVD+1:valCH,:);
182% BPMindex = family2atindex('BPMx',liste_dev_BPM);
183% spos = getspos('BPMx');
184% hcm = getsp('HCOR',liste_dev_HCOR,'struct');
185[U,S_V,V] = svd(Meffloc_V);
186setappdata(handles.caller,'S_V',S_V);
187
188
189
190
191% matrice singular values
192
193V = diag(S_V);
194
195% initalisation popupmenu
196set(handles.val_sing_V_popupmenu, 'String',...
197    {'liste valeurs singulières', V(:)});
198    %{'liste valeurs singulières', sprintf('%3.2f',V(:))});
199
200% positionner le popup à la dernière valeur (on prend par défaut toutes
201% les valeurs propres
202set(handles.val_sing_V_popupmenu,'Value',size(S_V,2)+1);
203setappdata(handles.caller,'valvp_V',size(S_V,2));
204k = get(handles.val_sing_V_popupmenu,'Value') - 1;
205if k==0
206    k = 1;
207end
208% replot des orbites
209h     = get(handles.axes1,'Children');
210hline = findobj(h,'-regexp','Tag','line[1,2]');
211
212% plot des valeurs singulières
213name=['axes' num2str(1)];
214axes(handles.(name));
215xdata = 1:size(S_V,2);
216
217%plot(xdata,V,'rs-','Tag','line1');
218if isequal(isempty(xdata),1)
219    xdata = [1];
220    V = [0];
221else
222    xlim([1 xdata(end)]);
223end
224set(hline(2),'XData',xdata,'YData',V,'Visible','On');
225set(hline(1),'XData',k,'YData',V(k),'Visible','On');
226
227
228% --------------------------------------------------------------------
229function FileMenu_Callback(hObject, eventdata, handles)
230% hObject    handle to FileMenu (see GCBO)
231% eventdata  reserved - to be defined in a future version of MATLAB
232% handles    structure with handles and user data (see GUIDATA)
233
234
235% --------------------------------------------------------------------
236function OpenMenuItem_Callback(hObject, eventdata, handles)
237% hObject    handle to OpenMenuItem (see GCBO)
238% eventdata  reserved - to be defined in a future version of MATLAB
239% handles    structure with handles and user data (see GUIDATA)
240file = uigetfile('*.fig');
241if ~isequal(file, 0)
242    open(file);
243end
244
245% --------------------------------------------------------------------
246function PrintMenuItem_Callback(hObject, eventdata, handles)
247% hObject    handle to PrintMenuItem (see GCBO)
248% eventdata  reserved - to be defined in a future version of MATLAB
249% handles    structure with handles and user data (see GUIDATA)
250printdlg(handles.figure1)
251
252% --------------------------------------------------------------------
253function CloseMenuItem_Callback(hObject, eventdata, handles)
254% hObject    handle to CloseMenuItem (see GCBO)
255% eventdata  reserved - to be defined in a future version of MATLAB
256% handles    structure with handles and user data (see GUIDATA)
257selection = questdlg(['Close ' get(handles.figure1,'Name') '?'],...
258                     ['Close ' get(handles.figure1,'Name') '...'],...
259                     'Yes','No','Yes');
260if strcmp(selection,'No')
261    return;
262end
263
264delete(handles.figure1)
265
266
267% --- Executes on selection change in val_sing_V_popupmenu.
268function val_sing_V_popupmenu_Callback(hObject, eventdata, handles)
269% hObject    handle to val_sing_V_popupmenu (see GCBO)
270% eventdata  reserved - to be defined in a future version of MATLAB
271% handles    structure with handles and user data (see GUIDATA)
272
273% Hints: contents = get(hObject,'String') returns val_sing_V_popupmenu contents as cell array
274%        contents{get(hObject,'Value')} returns selected item from val_sing_V_popupmenu
275
276
277S_V = getappdata(handles.caller,'S_V');
278
279% attribution du numero de la valeur propre (on enlève le titre)
280valvp_V = get(hObject,'Value')-1;
281
282setappdata(handles.caller,'valvp_V',valvp_V)
283handles.valvp_V = getappdata(handles.caller,'valvp_V');
284% % Update handles structure
285guidata(hObject, handles);
286
287h     = get(handles.axes1,'Children');
288hline = findobj(h,'-regexp','Tag','line[2]');
289
290% plot de la valeur singulière limite selectionnée
291name=['axes' num2str(1)];
292axes(handles.(name));
293
294% matrice singular values
295S_V = getappdata(handles.caller,'S_V');
296V = diag(S_V);
297set(hline(1),'XData',valvp_V,'YData',V(valvp_V),'Visible','On');
298
299
300disp('hello')
301
302
303% --- Executes during object creation, after setting all properties.
304function val_sing_V_popupmenu_CreateFcn(hObject, eventdata, handles)
305% hObject    handle to val_sing_V_popupmenu (see GCBO)
306% eventdata  reserved - to be defined in a future version of MATLAB
307% handles    empty - handles not created until after all CreateFcns called
308
309% Hint: popupmenu controls usually have a white background on Windows.
310%       See ISPC and COMPUTER.
311if ispc
312    set(hObject,'BackgroundColor','white');
313else
314    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
315end
316
317set(hObject, 'String', {'plot(rand(5))', 'plot(sin(1:0.01:25))', 'bar(1:.5:10)', 'plot(membrane)', 'surf(peaks)'});
318
319% % --- Executes on button press in rafraichir_pushbutton1.
320% function rafraichir_V_pushbutton_Callback(hObject, eventdata, handles)
321% % hObject    handle to rafraichir_pushbutton1 (see GCBO)
322% % eventdata  reserved - to be defined in a future version of MATLAB
323% % handles    structure with handles and user data (see GUIDATA)
324%
325% % axes(handles.axes1);
326% % cla;
327%
328% % recalculer la matrice S
329%
330% % nbre de correcteurs utilisés dans la correction SVD
331% nbcorrSVD_V = get(handles.nb_correcteurs_V_edit,'String');
332% nbcorrSVD_V = str2num(nbcorrSVD_V);
333% % correcteur actuellement selectionné
334% valCV = getappdata(handles.caller,'n_selection_CV');
335% %if isequal(valCV,0)|isequal(valCV,1)
336% if valCV<nbcorrSVD_V
337%     errordlg('avancez à un nombre adéquat de correcteurs !','Attention');
338%     % sortir de la fonction
339%     return
340% end
341% Meff_V = getappdata(handles.caller,'Meff_V');
342% BPMz = getappdata(handles.caller,'BPMz');
343% VCOR = getappdata(handles.caller,'VCOR');
344% % extraire la matrice
345% flag = 0;
346% liste_elem_BPM = [];
347% for j = 1 : length(BPMz.Position)
348%     if BPMz.Position(j)>VCOR.Position(valCV-nbcorrSVD_V+1) 
349%         if BPMz.Position(j)>VCOR.Position(valCV+1)
350%             break
351%         end
352%         flag = flag + 1;
353%         liste_elem_BPM = [liste_elem_BPM j];
354%         Meffloc_V(flag,:) = Meff_V(j,valCV-nbcorrSVD_V+1:valCV);
355%     end
356% end
357% % nbBPM  = flag;
358% % liste_dev_BPM = elem2dev('BPMx',liste_elem_BPM);
359% % HCOR_liste = getappdata(handles.figure1,'HCOR_liste');
360% % liste_dev_HCOR = HCOR_liste(valCH-nbcorrSVD+1:valCH,:);
361% % BPMindex = family2atindex('BPMx',liste_dev_BPM);
362% % spos = getspos('BPMx');
363% % hcm = getsp('HCOR',liste_dev_HCOR,'struct');
364% [U,S_V,V] = svd(Meffloc_V);
365% setappdata(handles.caller,'S_V',S_V);
366%
367%
368%
369%
370% % matrice singular values
371%
372% V = diag(S_V);
373%
374% % initalisation popupmenu
375% set(handles.val_sing_V_popupmenu, 'String',...
376%     {'liste valeurs singulières', V(:)});
377%     %{'liste valeurs singulières', sprintf('%3.2f',V(:))});
378%
379% % positionner le popup à la dernière valeur (on prend par défaut toutes
380% % les valeurs propres
381% set(handles.val_sing_V_popupmenu,'Value',size(S_V,2)+1);
382% setappdata(handles.caller,'valvp_V',size(S_V,2));
383% k = get(handles.val_sing_V_popupmenu,'Value') - 1;
384% if k==0
385%     k = 1;
386% end
387% % replot des orbites
388% h     = get(handles.axes1,'Children');
389% hline = findobj(h,'-regexp','Tag','line[1,2]');
390%
391% % plot des valeurs singulières
392% name=['axes' num2str(1)];
393% axes(handles.(name));
394% xdata = 1:size(S,2);
395%
396% %plot(xdata,V,'rs-','Tag','line1');
397% if isequal(isempty(xdata),1)
398%     xdata = [1];
399%     V = [0];
400% else
401%     xlim([1 xdata(end)]);
402% end
403% set(hline(2),'XData',xdata,'YData',V,'Visible','On');
404% set(hline(1),'XData',k,'YData',V(k),'Visible','On');
405%
Note: See TracBrowser for help on using the repository browser.