% BDT Filters % This file contains all of the filters for BDT. Filters have a % predefined format which must be followed in order to properly function % in BDT. % % 1) Filters are separated by empty lines. % % 2) The first line of a filter contains what will be shown in the % filters list. The first two characters of the name line must be %- so % that they will be recognized. % % 3) The remaining lines are the commands to be executed. Lines with %% % as the first two characters will be executed when the filter is added % while lines which begin with '% ' minus the quotes will be executed % when the graphs are plotted. Try to keep anything with user input % immediately after adding the filter. % % 4) Any data you want input immediately after adding the filter and then % used during plotting must be stored in the Filt.Filters structure. It % is important to note that Filt.Filters.String and Filt.Filters.Eval % must not be used as they are already used by BDT. % % 5) XData and YData are both numeric arrays. The XData holds the data % corresponding to the x-axis on each plot % % 6) Functions for graphical user input include: % inputdlg, logindlg, listdlg, questdlg, and other which can be found % in Matlab help. logindlg has been made by the creator of bdt2 to % hide passwords behind astrixes so it will not have a document entry % in Matlab help. For logindlg help type 'help logindlg' in the % command window. % % 7) Data available when the filter is added includes everything in the % Filt structure. XData, YData, and Filt are available when the graphs % are plotted. The data is un-normalized before filters are applied. % % 8) Filt field definitions (not all of these fields are guaranteed to be there): % Filt.DB - Database the data came from % Filt.Table - Table the data came from % Filt.XAxis - Column the x data came from % Filt.YAxis - Column the y data came from % Filt.Norm - Normalization factor for the data % Filt.Indices - Indices of currently selected points % Filt.SHandle - Handle of the selected points plot % Filt.Windows - Contains more fields with the handles of Data windows % Filt.Filters - Storage area for fields containing filter information % % Last Edit: 7/30/2007 %-X Lower Range %%xl = inputdlg({'X'},'Lower Range',1); %%Filt.Filters.XLRange = str2num(xl{1}); % XData(XData < Filt.Filters.XLRange) = NaN; %-X Upper Range %%xu = inputdlg({'X'},'Upper Range',1); %%Filt.Filters.XURange = str2num(xu{1}); % XData(XData > Filt.Filters.XURange) = NaN; %-Y Lower Range %%yl = inputdlg({'Y'},'Lower Range',1); %%Filt.Filters.YLRange = str2num(yl{1}); % YData(YData < Filt.Filters.YLRange) = NaN; %-Y Upper Range %%yu = inputdlg({'Y'},'Upper Range',1); %%Filt.Filters.YURange = str2num(yu{1}); % YData(YData > Filt.Filters.YURange) = NaN; %-Bias %%Filt.Filters.Bias = inputdlg('Value to Subtract','Bias',1); % YData = YData - str2num(Filt.Filters.Bias{1}); %-Curve Fit %%[Filt.Filters.fr_function_fit.Options Filt.Filters.fr_function_fit.Input Filt.Filters.fr_function_fit.Obs Filt.Filters.fr_function_fit.Func Filt.Filters.fr_function_fit.Init] = curve_fit(); % curve_fit_exec(Filt,XData,YData); %-Least Squares Fit, Geometric % XData(isnan(YData)) = []; % YData(isnan(YData)) = []; % YData(isnan(XData)) = []; % XData(isnan(XData)) = []; % [m b c sdevm sdevb] = lsqfitgm(XData,YData); % xtemp = XData; % ytemp = YData; % xtemp(isnan(ytemp)) = []; % ytemp(isnan(ytemp)) = []; % ytemp(isnan(xtemp)) = []; % xtemp(isnan(xtemp)) = []; % PData = get(p,'UserData'); % Color = get(p,'Color'); % Color = abs(Color-.3); % if ~~isfield(PData,'XAxis');PData.XAxis = [PData.XAxis '_fit'];else;PData.XAxis = '';end % if ~~isfield(PData,'YAxis');PData.YAxis = [PData.YAxis '_fit'];else;PData.YAxis = '';end % PData.Norm = 1; % PData.Indices = []; % PData.SHandle = []; % PData.Login = ''; % PData.Pass = ''; % PData.Comments = {['Fit Type = Least Squares, Geometric'];['Slope = ' num2str(m)];['Slope Standard Deviation = ' num2str(sdevm)];['Slope Intercept = ' num2str(b)];['Slope Intercept Standard Deviation = ' num2str(sdevb)];['Correlation Coefficient = ' num2str(c)];'Note: NaN''s have been ignored without respect to the NaN''s in the corresponding data set.'}; % NextP = get(Ax,'NextPlot'); % hold(Ax,'on') % p2 = plot(Ax,[min(xtemp) max(xtemp)],[min(xtemp)*m+b max(xtemp)*m+b],'Color',Color); % set(Ax,'NextPlot',NextP) % PData.PastHandles = p2; % PData.Filters.String = []; % PData.Filters.Eval = []; % set(p2,'UserData',PData); % cm_PlotInfo(get(Ax,'Parent'),[],p2) %-Polynomial %%temp = inputdlg({'N'},'Polynomial Degree',1); %%if ~isempty(temp);Filt.Filters.PolyDegree = str2num(temp{1});else;Filt.Filters.PolyDegree = [];end % NextP = get(Ax,'NextPlot'); % hold(Ax,'on') % Color = get(p,'Color'); % Color = abs(Color-.3); % PData = get(p,'UserData'); % XData2 = XData; % YData2 = YData; % XData2(isnan(YData2)) = []; % YData2(isnan(YData2)) = []; % YData2(isnan(XData2)) = []; % XData2(isnan(XData2)) = []; % P = polyfit(XData2,YData2,Filt.Filters.PolyDegree); % YData2 = polyval(P,XData); % p2 = plot(Ax,XData,YData2,'Color',Color,'LineWidth',2); % if ~~isfield(PData,'Comments');PData.Comments = [PData.Comments;{' ';'Polyfit Coefficients:'}];else;PData.Comments = {' ';'Polyfit Coefficients:'};end % PData.YAxis = [PData.YAxis ' Polyfit']; % for i=1:1:length(P);PData.Comments = [PData.Comments;num2str(P(i))];end % set(p2,'UserData',PData) % set(Ax,'NextPlot',NextP) % legend_update(Ax)