Download wangtzuming

Transcript
149
function PhaseShift_Callback(hObject, eventdata, handles)
XData = get(handles.plot1,'XData');
S = size(XData);
if S(1,2) < 2 %empty plot
return
end
[index1,index2] = IndexLoc(handles.aitime,XData(1,1),XData(1,end));
XData = handles.aitime(index1:index2,1);
if handles.menuindex(1,1)
Y = handles.PSDofSQA((index1:index2),1); %Capacitance, at Ch1
X = handles.PSDofSQA((index1:index2),2); %Conductance, at Ch2
else
Y = handles.aidata((index1:index2),1); %Capacitance, at Ch1
X = handles.aidata((index1:index2),2); %Conductance, at Ch2
end
The codes here assign data for offline phase shift. If square waves were applied, X and
Y are assigned from handles.PSDofSQA, else they are assigned from handles.aidata
directly.
PS = str2double(get(handles.Phase_Shift,'String'));
R_c = []; %R is the correlation coefficient
R_g = []; %R is the correlation coefficient
M = []; %method of correlation
if (handles.menuindex(1,1) && ~isnan(handles.shiftswitch) && (abs(PShandles.shiftvalue)) < 0.0001)
[PS,Cap,Cond,R_c,R_g] =
PhaseMatcher2(handles.shiftswitch,handles.aidata((index1:index2),
1),handles.aidata((index1:index2),2),Y,X,0.1);
handles.shiftvalue = PS;
set(handles.Phase_Shift,'String',num2str(PS));
if (handles.shiftswitch == 1)
M = 'G';
elseif (handles.shiftswitch == 0)
M = 'C';
else
M = 'C+G';
end
disp(['CorrMethod:',M,' P:',num2str(PS),' R_c:',num2str(R_c),'
R_g:',num2str(R_g)]);
The function calls PhaseMatcher2 to scan the phase only when all three criteria are
met: 1. SQA were used, 2. handles.shiftswitch is not a NaN, and 3. the input value in the
'Shift' edit box is not modified. Variable handles.shiftswitch is a NaN when the 'Userdefined' option in the 'Shift' context menu is selected. If the 'Shift' edit box is modified,