📄 modlplts.m
字号:
h = plot(x(jj),y(jj),'xb','MarkerSize',10);
hold off
end
s = ['modlplts(''lodmarkdel'',',as,')'];
z = get(gcf,'position');
y = figure('NumberTitle','off', ...
'Name','Plot of Raw Data','Menu','none', ...
'Position',[z(1) z(2)-10 380 285], ...
'UserData',h,'CloseRequestFcn',s,'Tag',int2str(gcf));
x = get(f(1,1),'UserData');
x = x(:,jj);
plot([1:length(x)],x,'+b',[1:length(x)],x,'-c')
xlabel('Sample Number')
ylabel('Measured Value')
title(['Raw Data for Variable ',int2str(jj)])
h = axis;
if h(1)*h(2)<-0.000001
vline(0);
end
if h(3)*h(4)<-0.000001
hline(0)
end
zoompls
set(g(1:size(g,1),1),'Enable','on')
if datstat
set(g(18,1),'Enable','off')
end
case 'scrdel'
g = get(findobj('Name','Plot Scores','Tag',as),'UserData');
set(g(1:size(g,1),1),'Enable','off')
z = get(gca,'children');
z = z(length(z));
x = get(z,'xdata');
y = get(z,'ydata');
jj = sampidr(x,y); %indice in plot
if ishold
h = plot(x(jj),y(jj),'*k','MarkerSize',10);
else
hold on
h = plot(x(jj),y(jj),'*k','MarkerSize',10);
hold off
end
cndlgpls(modl.irow(1,jj),g(18,1),'sample')
if strcmp(get(g(18,1),'Userdata'),'yes')
jk = modl.irow(1,jj);
modl.irow = delsamps(modl.irow',jj)';
modl.ypred = delsamps(modl.ypred,jj);
modl.scores = delsamps(modl.scores,jj);
modl.yres = delsamps(modl.yres,jj);
modl.tsq = delsamps(modl.tsq,jj);
modl.res = delsamps(modl.res,jj);
modl.lev = delsamps(modl.lev,jj);
modl.slbl = delsamps(modl.slbl,jj);
if size(x,2)>size(x,1)
set(z,'xdata',delsamps(x',jj)','ydata',delsamps(y',jj)')
else
set(z,'xdata',delsamps(x,jj),'ydata',delsamps(y,jj))
end
if ~isempty(modl.drow)
if isempty(find(modl.drow==jk))
modl.drow = [modl.drow, jk];
stat.modl = 'none';
set(b(1,1),'UserData',stat)
end
else
modl.drow = jk;
stat.modl = 'none';
set(b(1,1),'UserData',stat)
end
else
delete(h)
end
set(g(1:size(g,1),1),'Enable','on')
if datstat
set(g(18,1),'Enable','off')
end
case 'scrqcon'
g = get(gcf,'UserData');
set(g(1:size(g,1),1),'Enable','off')
z = get(gca,'children');
x = get(z(length(z)),'xdata');
y = get(z(length(z)),'ydata');
jj = sampidr(x,y);
if ishold
h = plot(x(jj),y(jj),'sb','MarkerSize',10);
else
hold on
h = plot(x(jj),y(jj),'sb','MarkerSize',10);
hold off
end
s = ['modlplts(''scrmarkdel'',',as,')'];
z = get(gcf,'position');
y = figure('NumberTitle','off', ...
'Name','Q Residual Contributions','Menu','none', ...
'Position',[z(1)+5 z(2)-15 380 285], ...
'UserData',h,'CloseRequestFcn',s,'Tag',int2str(gcf));
x = get(f(1,1),'UserData'); %raw
x = x(modl.irow(jj),:);
z = get(f(2,1),'UserData'); %modl
switch z.scale
case 'auto'
x = scale(x,z.meanx,z.stdx);
case 'mean'
x = scale(x,z.meanx);
end
[x,z] = resmtx(x,z.loads);
bar([1:length(x)],x,'b')
xlabel('Variable Number')
ylabel('Q Residual Contribution')
if ~datstat
jj = modl.irow(1,jj);
end
title(['Sample ',int2str(jj),' Q Residual = ',num2str(z)])
if modl.vlbl
y = find(x<0);
z = axis;
z2 = z(4)-max(x);
z2 = min([z2 z(4)]');
z3 = size(modl.vlbl,2)*0.04*(z(4)-z(3));
if z3>z2
z(4) = z3-z2+z(4);
axis(z)
end
x(y) = zeros(1,length(y));
x = x+0.01*z(4)*ones(1,length(x));
text([1:length(x)],x,modl.vlbl,'rotation',90);
end
hline(0)
zoompls
set(g(1:size(g,1),1),'Enable','on')
if datstat
set(g(18,1),'Enable','off')
end
case 'scrtcon'
g = get(gcf,'UserData');
set(g(1:size(g,1),1),'Enable','off')
z = get(gca,'children');
x = get(z(length(z)),'xdata');
y = get(z(length(z)),'ydata');
jj = sampidr(x,y);
if ishold
h = plot(x(jj),y(jj),'db','MarkerSize',10);
else
hold on
h = plot(x(jj),y(jj),'db','MarkerSize',10);
hold off
end
s = ['modlplts(''scrmarkdel'',',as,')'];
z = get(gcf,'position');
y = figure('NumberTitle','off', ...
'Name','Hotelling T^2 Contributions','Menu','none', ...
'Position',[z(1)+5 z(2)-15 380 285], ...
'UserData',h,'CloseRequestFcn',s,'Tag',int2str(gcf));
x = get(f(1,1),'UserData'); %raw
x = x(modl.irow(jj),:);
z = get(f(2,1),'UserData'); %modl
switch z.scale
case 'auto'
x = scale(x,z.meanx,z.stdx);
case 'mean'
x = scale(x,z.meanx);
end
y = diag((z.scores'*z.scores))/(size(z.scores,1)-1);
if size(y,2)>size(y,1)
y = y';
end
y = [ones(size(z.scores,2),1),y];
z = z.loads;
[x,z] = tsqmtx(x,z,y);
% y = sqrt(1./diag((z.scores'*z.scores)));
% x = z.scores(jj,:)*diag(y)*z.loads';
% z = z.tsq(jj);
bar([1:length(x)],x,'b')
xlabel('Variable Number')
ylabel('Hotelling T^2 Contribution')
if ~datstat
jj = modl.irow(1,jj);
end
title(['Sample ',int2str(jj),' Hotelling T^2 = ',num2str(z)])
if modl.vlbl
y = find(x<0);
z = axis;
z2 = z(4)-max(x);
z2 = min([z2 z(4)]');
z3 = size(modl.vlbl,2)*0.04*(z(4)-z(3));
if z3>z2
z(4) = z3-z2+z(4);
axis(z)
end
x(y) = zeros(1,length(y));
x = x+0.01*z(4)*ones(1,length(x));
text([1:length(x)],x,modl.vlbl,'rotation',90);
end
hline(0)
zoompls
set(g(1:size(g,1),1),'Enable','on')
if datstat
set(g(18,1),'Enable','off')
end
case 'scrinfo'
g = get(gcf,'UserData');
set(g(1:size(g,1),1),'Enable','off')
z = get(gca,'children');
x = get(z(length(z)),'xdata');
y = get(z(length(z)),'ydata');
jj = sampidr(x,y);
if ishold
h = plot(x(jj),y(jj),'xb','MarkerSize',10);
else
hold on
h = plot(x(jj),y(jj),'xb','MarkerSize',10);
hold off
end
s = ['modlplts(''scrmarkdel'',',as,')'];
z = get(gcf,'position');
y = figure('NumberTitle','off', ...
'Name','Sample Info','Color',[0 0 0],'Menu','none', ...
'Position',[z(1)+35 z(2)-40 220 150], ...
'UserData',h,'CloseRequestFcn',s,'Tag',int2str(gcf));
x = uicontrol('Parent',y,'BackgroundColor',[1 1 1], ...
'Style','text','Position',[3 3 214 144], ...
'FontName','geneva','FontSize',10, ...
'HorizontalAlignment','left');
set(x,'Units','normalized')
if datstat
if isempty(test.slbl)
s = ' ';
else
s = test.slbl(jj,:);
end
y1 = ['Q Residual = ',num2str(test.res(jj))];
z = ['Hotelling T^2 = ',num2str(test.tsq(jj))];
else
if isempty(modl.slbl)
s = ' ';
else
s = modl.slbl(jj,:);
end
y1 = ['Q Residual = ',num2str(modl.res(jj))];
z = ['Hotelling T^2 = ',num2str(modl.tsq(jj))];
jj = modl.irow(1,jj);
end
if ~get(g(13,1),'value')
y2 = [' (95% limit = ',num2str(modl.reslim),')'];
z2 = [' (95% limit = ',num2str(modl.tsqlim),')'];
else
s2 = get(g(12,1),'string');
s3 = str2num(s2);
m = size(modl.loads,2);
nx = length(modl.icol);
mx = length(modl.irow);
if m<nx
if isfield(modl,'reseig')
s4 = reslim(0,modl.reseig,s3);
else
df = (mx-1)*nx-m*max([mx,nx]');
s4 = sum(modl.res)/mx*ftest((100-s3)/100,df/mx,df);
oldqlim = 1;
end
else
s4 = 0;
end
s3 = tsqlim(length(modl.irow),get(f(4,1),'UserData'),s3);
y2 = [' (',s2,'% limit = ',num2str(s4),')'];
z2 = [' (',s2,'% limit = ',num2str(s3),')'];
end
z = str2mat(['Sample ',int2str(jj)],s,y1,y2,z,z2);
set(x,'String',z)
set(g(1:size(g,1),1),'Enable','on')
if datstat
set(g(18,1),'Enable','off')
end
case 'scrmarkdel'
h = findobj('Name','Plot Scores','Tag',as);
if h
h = get(gcf,'UserData');
end
if ishandle(h)
delete(h)
closereq
else
closereq
end
case 'lodmarkdel'
h = findobj('Name','Plot Loads','Tag',as);
if h
h = get(gcf,'UserData');
end
if ishandle(h)
delete(h)
closereq
else
closereq
end
case 'lodinfo'
g = get(gcf,'UserData');
set(g(1:size(g,1),1),'Enable','off')
z = get(gca,'children');
x = get(z(length(z)),'xdata');
y = get(z(length(z)),'ydata');
jj = sampidr(x,y);
if ishold
h = plot(x(jj),y(jj),'xb','MarkerSize',10);
else
hold on
h = plot(x(jj),y(jj),'xb','MarkerSize',10);
hold off
end
s = ['modlplts(''lodmarkdel'',',as,')'];
z = get(gcf,'position');
y = figure('NumberTitle','off', ...
'Name','Variable Info','Color',[0 0 0], ...
'Position',[z(1)+35 z(2)-40 220 150], ...
'Menu','none','Tag',int2str(gcf), ...
'UserData',h,'CloseRequestFcn',s);
x = uicontrol('Parent',y,'BackgroundColor',[1 1 1], ...
'Style','text','Position',[3 3 214 144], ...
'FontName','geneva','FontSize',10, ...
'HorizontalAlignment','left');
set(x,'Units','normalized')
if isempty(modl.vlbl)
s = ' ';
else
s = modl.vlbl(jj,:);
end
jj = modl.icol(1,jj);
z = str2mat(['Variable ',int2str(jj)],s);
y = get(f(1,1),'UserData');
y = y(:,jj);
s1 = sprintf('mean = %g',mean(y));
s2 = sprintf('std = %g',std(y));
z = str2mat(z,s1,s2);
set(x,'String',z)
set(g(1:size(g,1),1),'Enable','on')
if datstat
set(g(18,1),'Enable','off')
end
case 'loddel'
%not tested, should be changed!
g = get(gcf,'UserData');
set(g(1:size(g,1),1),'Enable','off')
z = get(gca,'children');
x = get(z(length(z)),'xdata');
y = get(z(length(z)),'ydata');
jj = sampidr(x,y); %indice in plot
if ishold
h = plot(x(jj),y(jj),'*k','MarkerSize',10);
else
hold on
h = plot(x(jj),y(jj),'*k','MarkerSize',10);
hold off
end
jj = modl.icol(1,jj); %variable number
cndlgpls(jj,g(18,1),'variable')
if strcmp(get(g(18,1),'Userdata'),'yes')
modl.dcol = [modl.dcol, jj];
stat.modl = 'none';
else
delete(h)
end
set(g(1:size(g,1),1),'Enable','on')
if datstat
set(g(18,1),'Enable','off')
end
case 'limitchk'
g = get(gcf,'UserData');
set(g(3,1),'Enable','on')
if get(g(13,1),'Value')
set(g(12,1),'Enable','on')
else
set(g(12,1),'Enable','off')
end
case 'g3on'
g = get(gcf,'UserData');
set(g(3,1),'Enable','on')
end
set(f(2,1),'UserData',modl)
set(b(1,1),'UserData',stat)
modlgui('nothing',fighand)
if oldqlim == 1
wrnstr = ['Q limit estimated using outdated method,'
'limit value is likely significantly low.'
'Please update your model with UPDATEMOD '];
warndlg(wrnstr,'Q Limit Warning')
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -