www.gusucode.com > mbctools 工具箱 matlab 源码程序 > mbctools/@mdev_local/TestChooser.m
function SNo = TestChooser(mdev,SNo) %TESTCHOOSER listview to choose tests % % SweepIndex = TestChooser(mdev) opens a gui that contains a list and % allows the user to select a new sweep to display. The index of the % sweep in the current list of sweeps is returned. % Copyright 2000-2015 The MathWorks, Inc. and Ford Global Technologies, Inc. if nargin<2 View= GetViewData(MBrowser); SNo = View.SweepPos; end [dlg,h]= i_create; X= getdata(mdev,'FIT'); globalNames = get(X{2},'name'); ColNames = [{'Number','RMSE'},globalNames(:)',{'Note'}]; h.Peer.setColumnData(ColNames); h.Peer.setColumnWidths([50 65, repmat(65,1,length(globalNames)),300]); Y= getdata(mdev,'Y'); TNo= testnum(Y); Data = cell(size(Y,3),length(ColNames)); col = zeros(size(Y,3),3); if size(mdev.Notes,1)~=size(Y,3) mdev.Notes = cell( size(Y,3),2); mdev.Notes(:,1)= {''}; mdev.Notes(:,2)= {[0 0 0]}; xregpointer(mdev); end for i=1:size(Y,3); % construct table data % test number Data{i,1}= num2str(TNo(i)); if mdev.FitOK(i) % RMSE Data{i,2} = sqrt(mdev.MLE.SSE_nat(i)/mdev.MLE.df(i)); % Notes Data{i,end}= char(mdev.Notes{i,1}); % colot col(i,:)=mdev.Notes{i,2}*255; else Data{i,2} = NaN; Data{i,end}= 'Not Fitted'; end % global variables xg = X{2}{i}; Data(i,3:2+length(xg))= num2cell(xg); end h.Peer.setData(Data); h.Peer.setRowColors(col(:,1),col(:,2),col(:,3)); % Select the current test h.selectRows(SNo); Status = dlg.showDialog; SNo= 0; if strcmp(Status,'OK') SNo = double(h.getSelectedRows); if isempty(SNo) % deal with no rows selected SNo=0; end end delete(dlg) function [dlg,h]= i_create dlg = mbcgui.container.Dialog(... 'Name','Test Selector',... 'Buttons', 'OK_CANCEL', ... 'Size', [440 400]); h = mbcwidgets.List('Parent',dlg.Figure,... 'Grid',true,... 'Tag','TestChooserTable',... 'BorderType', 'beveledin', ... 'SelectionMode','SingleRow'); L = handle.listener(h.Peer, 'ActionPerformed', {@i_listclick, dlg}); set(dlg.Figure, 'UserData', L); dlg.Content = h; function i_listclick(~, ~, dlg) dlg.closeDialog('OK');