% 20061126 Jan Rohlén % Illustration av multivariat problem. % close all hidden N=100; % Antal provpunkter mu = [10 12]; sigma = [0.2 0.15; 0.15 0.2]; X = mvnrnd(mu,sigma,N); % tillverka en konstig punkt [Q,w]=max(X(:,1)); X(w,2)=min(X(:,2)); figure set(gcf,'Position',[520 328 560 560]) % Gör figuren rektangulär % x pos y pos bredd höjd HA1=axes('Position',[0.1300 0.7093 0.2157 0.2157]) HA2=axes('Position',[0.3934 0.7093 0.5 0.2157]) HA3=axes('Position',[0.1300 0.13 0.2157 0.5]) axes(HA1) plot(X(:,1),X(:,2),'.k') hold plot(X(w,1),X(w,2),'ob') axes(HA2) plot(X(:,2),'.-k') hold S2=std(X(:,2)); M2=mean(X(:,2)); UCL2=M2+3*S2; LCL2=M2-3*S2; CL2=M2; plot(X(:,2)*0+UCL2,'r') plot(X(:,2)*0+LCL2,'r') plot(X(:,2)*0+CL2,'r--') set(HA1,'YLim',get(HA2,'YLIM')) axes(HA3) plot(X(:,1),1:N,'.-k') hold S1=std(X(:,1)); M1=mean(X(:,1)); UCL1=M1+3*S1; LCL1=M1-3*S1; CL1=M1; plot(X(:,1)*0+UCL1,1:N,'r') plot(X(:,1)*0+LCL1,1:N,'r') plot(X(:,1)*0+CL1,1:N,'r--') xlabel('x_1') set(HA3,'YAxisLocation','right') set(HA2,'YAxisLocation','right') axes(HA2) ylabel('x_2') %Ritar in styrgränserna i gemensamma diagrammet axes(HA1) plot(get(HA1,'Xlim'),[UCL2 UCL2],'r') plot(get(HA1,'Xlim'),[LCL2 LCL2],'r') plot([UCL1 UCL1],get(HA1,'Ylim'),'r') plot([LCL1 LCL1],get(HA1,'Ylim'),'r')