📄 modlplts.m
字号:
df = (m-1)*nx-n*max([m,nx]');
lm2 = sum(modl.res)/m*ftest((100-alp)/100,df/m,df);
oldqlim = 1;
end
else
lm2 = 0;
end
h1 = max([lm2; max(y)]);
h(4) = 1.05*h1;
elseif pc2==3 % y = T^2 lm2
h(3) = 0;
lm2 = tsqlim(m,n,alp);
h1 = max([lm2; max(y)]);
h(4) = 1.05*h1;
elseif (pc2>3)&(pc2<n+4) %LVs y = pc-3 lm1
mn2 = mean(modl.scores(:,pc2-3));
lm2 = std(modl.scores(:,pc2-3))*ttestp(alq,m-pc2+3,2);
h0 = min([mn2-lm2; min(y)]);
h1 = max([mn2+lm2; max(y)]);
dh = 0.05*(h1-h0);
h(3) = h0-dh;
h(4) = h1+dh;
end
axis(h)
if (pc2>3)&(pc2<n+4) %LVs y = pc-3 lm1
hline(mn2+lm2,'--g'), hline(mn2-lm2,'--g')
else
hline(lm2,'--g')
end % end of x = sample
elseif pc==2 % x = Q lm1
if n<nx
if isfield(modl,'reseig')
lm1 = reslim(0,modl.reseig,alp);
else
df = (m-1)*nx-n*max([m,nx]');
lm1 = sum(modl.res)/m*ftest((100-alp)/100,df/m,df);
oldqlim = 1;
end
else
lm1 = 0;
end
h(1) = 0;
h1 = max([lm1; max(x)]);
h(2) = 1.05*h1;
if pc2==2 % y = Q lm2
h(3) = 0;
lm2 = lm1;
h1 = max([lm2; max(y)]);
h(4) = 1.05*h1;
elseif pc2==3 % y = T^2 lm2
h(3) = 0;
lm2 = tsqlim(m,n,alp);
h1 = max([lm2; max(y)]);
h(4) = 1.05*h1;
elseif (pc2>3)&(pc2<n+4) %LVs y = pc-3 lm1
mn2 = mean(modl.scores(:,pc2-3));
lm2 = std(modl.scores(:,pc2-3))*ttestp(alq,m-pc2+3,2);
h0 = min([mn2-lm2; min(y)]);
h1 = max([mn2+lm2; max(y)]);
dh = 0.05*(h1-h0);
h(3) = h0-dh;
h(4) = h1+dh;
end
axis(h)
vline(lm1,'--g')
if (pc2>3)&(pc2<n+4) %LVs y = pc-3
hline(mn2+lm2,'--g'), hline(mn2-lm2,'--g')
else
hline(lm2,'--g')
end % end of x = Q
elseif pc==3 % x = T^2 lm1
lm1 = tsqlim(m,n,alp);
h(1) = 0;
h1 = max([lm1; max(x)]);
h(2) = 1.05*h1;
if pc2==2 % y = Q lm2
h(3) = 0;
if n<nx
if isfield(modl,'reseig')
lm2 = reslim(0,modl.reseig,alp);
else
df = (m-1)*nx-n*max([m,nx]');
lm2 = sum(modl.res)/m*ftest((100-alp)/100,df/m,df);
oldqlim = 1;
end
else
lm2 = 0;
end
h1 = max([lm2; max(y)]);
h(4) = 1.05*h1;
elseif pc2==3 % y = T^2 lm2
h(3) = 0;
lm2 = lm1;
h1 = max([lm2; max(y)]);
h(4) = 1.05*h1;
elseif (pc2>3)&(pc2<n+4) %LVs y = pc-3 lm1
mn2 = mean(modl.scores(:,pc2-3));
lm2 = std(modl.scores(:,pc2-3))*ttestp(alq,m-pc2+3,2);
h0 = min([mn2-lm2; min(y)]);
h1 = max([mn2+lm2; max(y)]);
dh = 0.05*(h1-h0);
h(3) = h0-dh;
h(4) = h1+dh;
end
axis(h)
vline(lm1,'--g')
if pc2>3
hline(mn2+lm2,'--g'), hline(mn2-lm2,'--g')
else
hline(lm2,'--g')
end % end of x = T^2
elseif (pc>3)&(pc<n+4) %LVs x = pc-3 lm1
mn1 = mean(modl.scores(:,pc-3));
lm1 = std(modl.scores(:,pc-3))*ttestp(alq,m-pc+3,2);
h0 = min([mn1-lm1; min(x)]);
h1 = max([mn1+lm1; max(x)]);
dh = 0.05*(h1-h0);
h(1) = h0-dh;
h(2) = h1+dh;
if pc2==2 % Q
h(3) = 0;
if n<nx
if isfield(modl,'reseig')
lm2 = reslim(0,modl.reseig,alp);
else
df = (m-1)*nx-n*max([m,nx]');
lm2 = sum(modl.res)/m*ftest((100-alp)/100,df/m,df);
oldqlim = 1;
end
else
lm2 = 0;
end
h1 = max([lm2; max(y)]);
h(4) = 1.05*h1;
elseif pc2==3 % T
h(3) = 0;
lm2 = tsqlim(m,n,alp);
h1 = max([lm2; max(y)]);
h(4) = 1.05*h1;
elseif (pc2>3)&(pc2<n+4) %LVs
mn2 = mean(modl.scores(:,pc2-3));
lm2 = std(modl.scores(:,pc2-3))*ttestp(alq,m-pc2+3,2);
h0 = min([mn2-lm2; min(y)]);
h1 = max([mn2+lm2; max(y)]);
dh = 0.05*(h1-h0);
h(3) = h0-dh;
h(4) = h1+dh;
end
axis(h)
if (pc2>3)&(pc2<n+4) %LVs
ellps([mn1 mn2],[lm1 lm2],'--g')
else
vline(mn1+lm1,'--g'), vline(mn1-lm1,'--g')
hline(lm2,'--g')
end % end of x = pc-3
end
end
h = axis;
if h(1)*h(2)<-0
vline(0);
end
if h(3)*h(4)<-0
hline(0)
end
else
set(g(16:size(g,1)-1,1),'Enable','off')
plot3(x,y,z,'or')
s = ' ';
n = length(modl.irow);
v = size(scr,1);
if get(g(10,1),'Value')==2 %put numbers on
if datstat
s = [s(ones(v,1)),int2str([1:v]')];
else
s = [s(ones(n,1)),int2str((modl.irow)')];
end
elseif (get(g(10,1),'Value')==3)&~isempty(lbl)
if datstat
s = [s(ones(v,1)),lbl];
else
s = [s(ones(n,1)),lbl];
end
end
if get(g(10,1),'Value')>1
text(x,y,z,s,'Fontname','geneva','Fontsize',10);
end
drop = 1;
if drop==1
h = axis; axis(h)
if ishold
for jj=1:length(z)
plot3([1 1]*x(jj),[1 1]*y(jj),[h(5) z(jj)],'-g')
end
else
hold on
for jj=1:length(z)
plot3([1 1]*x(jj),[1 1]*y(jj),[h(5) z(jj)],'-g')
end
hold off
end
end
grid on
highorb
end
xlabel(sx)
ylabel(sy)
title('Scores Plot')
if z
zlabel(sz)
end
v = axis;
set(g(20,1),'UserData',v)
set(g(3,1),'Enable','off')
case 'plotloadsbut'
if isempty(modl.vscl)
var = modl.icol';
else
var = modl.vscl(modl.icol);
end
g = get(gcf,'UserData');
pc = get(g(4,1),'Value');
son = 0;
n = size(modl.loads,2); %number of LVs in model
if pc==1 %variable
x = var;
sx = 'Variable Number';
son = 1;
elseif (pc>1)&(pc<n+2)
x = modl.loads(:,pc-1);
sx = sprintf('%5.2f',modl.ssq(pc-1,2));
sx = [' (',sx,'%)'];
sx = ['LV ',int2str(pc-1),sx];
else
x = modl.reg(:,pc-n-1);
sx = ['Regression Coefficients for y(:,',int2str(pc-n-1),')'];
end
pc = get(g(6,1),'Value');
if pc==1 %variable
y = var;
sy = 'Variable Number';
son = 1;
elseif (pc>1)&(pc<n+2)
y = modl.loads(:,pc-1);
sy = sprintf('%5.2f',modl.ssq(pc-1,2));
sy = [' (',sy,'%)'];
sy = ['LV ',int2str(pc-1),sy];
else
y = modl.reg(:,pc-n-1);
sy = ['Regression Coefficients for y(:,',int2str(pc-n-1),')'];
end
pc = get(g(8,1),'Value');
if pc==1 %none
z = [];
elseif (pc>1)&(pc<n+2)
z = modl.loads(:,pc-1);
sz = sprintf('%5.2f',modl.ssq(pc-1,2));
sz = [' (',sz,'%)'];
sz = ['LV ',int2str(pc-1),sz];
else
z = modl.reg(:,pc-n-1);
sz = ['Regression Coefficients for y(:,',int2str(pc-n-1),')'];
end
if isempty(z)
h = findobj('Tag',['HighOrb',int2str(gcf)]);
if h
h = get(h,'UserData');
delete(h(:,1));
end
set(g(12:size(g,1),1),'Enable','on')
if datstat
set(g(18,1),'Enable','off')
end
plot(x,y,'+b')
if son
if ishold
plot(x,y,'-g')
else
hold on, plot(x,y,'-g'), hold off
end
end
h = axis;
if h(1)*h(2)<-0
vline(0);
end
if h(3)*h(4)<-0
hline(0)
end
s = ' ';
n = length(modl.icol);
if get(g(10,1),'Value')==2 %put numbers on
s = [s(ones(n,1)),int2str((modl.icol)')];
elseif (get(g(10,1),'Value')==3)&~isempty(modl.vlbl)
s = [s(ones(n,1)),modl.vlbl(modl.icol,:)];
end
if get(g(10,1),'Value')>1
text(x,y,s,'Fontname','geneva','Fontsize',10);
end
set(g(20,1),'UserData',h) %set 1st axis for zoom
else
set(g(12:size(g,1)-1,1),'Enable','off')
plot3(x,y,z,'+b')
s = ' ';
n = length(modl.icol);
if get(g(10,1),'Value')==2 %put numbers on
s = [s(ones(n,1)),int2str((modl.icol)')];
elseif (get(g(10,1),'Value')==3)&~isempty(modl.vlbl)
s = [s(ones(n,1)),modl.vlbl(modl.icol,:)];
end
if get(g(10,1),'Value')>1
text(x,y,z,s,'Fontname','geneva','Fontsize',10);
end
drop = 1;
if drop==1
h = axis; axis(h)
if ishold
for jj=1:length(z)
plot3([1 1]*x(jj),[1 1]*y(jj),[h(5) z(jj)],'-c')
end
else
hold on
for jj=1:length(z)
plot3([1 1]*x(jj),[1 1]*y(jj),[h(5) z(jj)],'-c')
end
hold off
end
end
grid on
highorb
end
xlabel(sx)
ylabel(sy)
title('Loads Plot')
if z
zlabel(sz)
end
v = axis;
set(g(20,1),'UserData',v)
set(g(3,1),'Enable','off')
case 'scrraw'
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','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(modl.irow(1,jj),:);
plot([1:length(x)],x,'+b',[1:length(x)],x,'-c')
xlabel('Variable Number')
ylabel('Measured Value')
title(['Raw Data for Sample ',int2str(modl.irow(1,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 'lodraw'
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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -