% This program is used to explain how PCA works and the idea behind the
% method. This example is given in the ISA book (Chapter 8, simple example)
% The process is composed of a valve a thermometer and a fermenter. The
% valve is used to control the flow rate of cooling water. The thermometer
% is used to measure the temperature of the fermenter.
% The steady state of the system is: valve=10% max. Temperature T=25 D.
% YANG ZHANG Email: yz@che.utexas.edu
% 2006-April, UTexas-Austin
clear all
% Give valve set points and fermenter temperature.
% Valve=10+rand(1,10)-0.5; % ten value of Valve around mean.
% Temp=25-(Valve-10)+(rand(1,10)-0.5)*0.5; % 10 value of Temp: T=2.5*valve + noise
Temp = [2.5000e+001 2.5000e+001 2.5000e+001 2.5300e+001 2.5200e+001 2.5200e+001 2.4800e+001 2.4700e+001 2.5100e+001 2.4700e+001];
Valve = [1.0100e+001 9.9000e+000 1.0000e+001 9.8000e+000 9.9000e+000 9.8000e+000 1.0100e+001 1.0300e+001 1.0000e+001 1.0100e+001];
% Define database
x=[Valve;Temp]';
figure(1)
plot(x(:,1),x(:,2),'ko')
xlabel('Valve Position (%)')
ylabel('Fermenter Temperature (C)')
% Calculate the covariance of dataset x (relationship between Valve and
% Temperature)
covariance=cov(x);
% Singular Value Decomposition x=T*E*P
% E is the eignvalue of x; U is orthnormal; V=U'.
%[U E V]=svd(covariance);
%U=U'; V=V';
[U E] = eig(covariance);
E = diag([E(2,2),E(1,1)]); % arrange the Eignvalue in a decending order
U = [U(:,2),U(:,1)]; % arrange the Eignvector to make it compatable with Eignvalue.
% Mean center the raw data
Valvebar=x(:,1)-mean(x(:,1));
Tempbar=x(:,2)-mean(x(:,2));
xbar=[Valvebar,Tempbar];
% Principal axis rotation of the covariance matrix.
z=U'*xbar';
z=z';
%covz is the covariance matrix of principal components which is equal to E
%matrix. The variance of transformed variable (z1 & z2) will have variance
%0.2283 and 0.0123 respectively.
covz=U'*covariance*U;
% The first column of U factor is - and + with nearly equal value which
% means the first principal component is related to variability which both
% measurements have difference. The second column is both positive which
% means the 2nd PC is concentrate on the varaiability of the common between
% the two.
% scaling of PCS.
for i=1:2
Vs(:,i)=sqrt(E(i,i))*U(:,i);
Ws(:,i)=U(:,i)/sqrt(E(i,i));
end
% after rescale: Vs'*Vs=E; V'*COV*Vs=E^2; Ws'*Ws=inv(E); Ws'*COV*Ws=I
y=Ws'*xbar';
%define T2
T2=diag(y'*y);
% find the control limit of T2
p=2; %PC number
n=10; % sample number
T2Upper=p*(n-1)/(n-p)*finv(0.95,p,n-p);
% draw the T2 control charts
figure(2)
plot(T2,'ko')
hold on
plot(T2Upper*ones(1,13),'k')
xlabel('Sample Number')
ylabel('T2 Score')
hold off
% Draw the control ellipse
% s1^2*s2^2/(s1^2*s2^2-s12^2)*[(x1-x1mean)^2/s1^2+(x2-x2mean)^2/s2^2-2*s12(
% x1-x1mean)(x2-x2mean)/s1^2/s2^2]=T2^2(upper control limit)
% S=covariance;
% a=S(1)*S(4)/(S(1)*S(4)-S(2)^2);
% b=xbar(:,1).^2/S(1)+xbar(:,2).^2/S(4)-2*S(2)*xbar(:,1).*xbar(:,2)./S(1)/S(4);
% error detection
% two new points is added to be detected which are [10.1,25.2];[9.9;24];
% plot two values with the original 10.
Valve2=[10.2,9.9];Temp2=[25.1,25.5];
figure(1)
hold on
plot(Valve2,Temp2,'k*')
hold off
% plot the control charts for valve and temperature separately.
figure(3)
hold on
plot(1:10,Valve,'ko')
plot(11:12,Valve2,'k*')
plot(0:13, mean(Valve)*ones(1,14),'k')
plot(0:13, (mean(Valve)-std(Valve)*2)*ones(1,14),'k')
plot(0:13, (mean(Valve)+std(Valve)*2)*ones(1,14),'k')
xlabel('Sample Number')
ylabel('Valve Position (%)')
hold off
figure(4)
hold on
plot(1:10,Temp,'ko')
plot(11:12,Temp2,'k*')
plot(0:13, mean(Temp)*ones(1,14),'k')
plot(0:13, (mean(Temp)+std(Temp)*2)*ones(1,14),'k')
plot(0:13, (mean(Temp)-std(Temp)*2)*ones(1,14),'k')
xlabel('Sample Number')
ylabel('Temperature (C)')
hold off
% transform new observations to PC axis
y2=Ws'*([Valve2-mean(Valve);Temp2-mean(Temp)]);
% plot the control charts for principal components
figure(5)
hold on
plot(1:10,y(1,:),'ko')
plot(11:12,y2(1,:),'k*')
plot(0:13, mean(y(1,:))*ones(1,14),'k')
plot(0:13, -2*ones(1,14),'k')
plot(0:13, 2*ones(1,14),'k')
xlabel ('Sample Number')
ylabel ('Principal Component 1')
hold off
figure(6)
hold on
plot(1:10,y(2,:),'ko')
plot(11:12,y2(2,:),'k*')
plot(0:13,mean(y(2,:))*ones(1,14),'k')
plot(0:13, -2*ones(1,14),'k')
plot(0:13, 2*ones(1,14),'k')
xlabel ('Sample Number')
ylabel ('Principal Component 2')
hold off
% plot the T2 chart for the two new points
figure(2)
T22=diag(y2'*y2);
hold on
plot([11,12],T22,'k*')
hold off
% draw the control ellipse
ra = sqrt(T2Upper*E(1,1));
rb = sqrt(T2Upper*E(2,2));
V=[sqrt(E(1,1))*U(:,1),sqrt(E(2,2))*-U(:,2)];
k1 = V(2,1)/V(1,1);
k2 = V(2,2)/V(1,2);
ang = atan(k1); %atan(k1);
x0 = mean(x(:,1));
y0 = mean(x(:,2));
% i = 9.5:0.01:10.5;
% s = 9.72:0.01:10.3;
% j = k1*i + 42.6303;
% l = k2*s + 19.3279;
figure (7)
h=ellipse(ra,rb,ang,x0,y0,'k',1000);
hold on
plot(x(:,1),x(:,2),'ko')
plot(Valve2, Temp2,'k*')
% plot(i,j)
% plot(s,l)
xlabel ('Valve Position')
ylabel ('Temperature')
hold off
相关推荐
主成分分析(PCA)及其可视化——matlab
X= csvread('文件路径',1,0); %读取数据文件,第一行不读取 T = readtable('文件路径');%读取文件中的所有数据 举例: data = [1,-0.2,0.3,0.8,-0.5 -0.2,1,0.6,-0.7,0.2 0.3,0.6,1,0.5,-0.3 0.8,-0.7,0.5,1,0.7 -0.5,0.2,-0.3,0.7,1] 运行结果: mapping.mean = mean(data, 1) %..
This program is used to explain how PCA works and the idea behind the method.
% This program is used to explain how PCA works and the idea behind the% method. This example is given in the ISA book (Chapter 8, simple example)% The process is composed of a valve a thermomete
主成分分析(PCA)——matlab程序及函数详解
参考来源: http://www.cnblogs.com/Hand-Head/articles/5156435.html http://www.matlabsky.com/thread-11751-1-1.html matlab帮助文档 例子: 它使用了衡量美国329个城市生活质量的9个指标:气候、住房、健康、犯罪率、交通、教育、艺术、娱乐和经济。 对于各指标,越高表示越好,如
第一个racket程序:获得字符串中的数字
#! /usr/bin/env racket #lang racket #| NAME: getModelNumber.rkt This program is used to get model number based on the input model file name. USAGE: ./getModelNumber.rkt modelfi
PCA:matlab主成份分析
通常对于高维数据需要进行降维,matlab中有pca进行数据分析,进行主成份分析:principal component analysis。
主成分分析(PCA)(matlab版本)
一、基础知识 假设两个样本X、Y,它们的均值分别为X‾\overline{X}X、Y‾\overline{Y}Y,样本X和样本Y的协方差为: Cov(X,Y)=∑i=1n(Xi−X‾)(Yi−Y‾)n−1 Cov(X,Y) = \frac{\sum_{i=1}^{n}(X_i-\overline{X})(Y_i-\overline{Y})}{n-1} Cov(X,Y)=n−1∑i=1n(Xi...
Linux下C 文件读写程序
直接上程序: //ddim.c #include /* *This program is used to read some data from the data file *and then to process. */ int main(void) { int scores[5][3];//score array float average; flo
基于Matlab实现PCA算法(附上多个案例源码)
基于Matlab实现PCA算法(附上多个案例源码)
The file is absent or does not have execute permission This file is needed to run this program
需要将另一个服务器上的tomcat复制到本服务器上。执行启动命令时报这个错误。意思就是:该文件不存在或没有执行权限运行该程序需要该文件。显然不可能是不存在的。那就是没有执行权限了。
Matlab中PCA主成分分析的实现步骤详解
在数学中,对于一个(m \times m)的方阵(A),如果存在非零向量(v)和标量(\lambda),满足以下等式:那么,(v)被称为(A)的特征向量,(\lambda)被称为相应的特征值。特征值的大小指示了特征向量所代表的方向在变换矩阵(A)作用下伸缩的倍数。在PCA的上下文中,特征向量指示了数据变异性最大的方向,而特征值的大小则表明了数据在这个方向上的方差大小。在机器学习领域,PCA经常被用作数据预处理的手段之一。
一文搞懂STM32定时器翻转模式(产生多路频率、占空比的PWM)
(产生多路频率、占空比的PWM)
主成分分析法(PCA)及MATLAB实现
主成分分析法(PCA)及MATLAB程序实现
ndnSIM学习笔记(一)
在接下来的一段时间要用ndnSIM来做自己的仿真网络,需要系统的学习相关内容,以下为内容记录。1.安装 1.1核心依赖(必需的) • python >= 2.6 • libsqlite3 • libcrypto++ • pkg-config • Boost lib...
主成分分析(PCA)算法模型实现及分析(MATLAB实现)PCA降维
主成分分析(PCA)是一种能够极大提升无监督特征学习速度的数据降维算法。主成分分析(Principal Component Analysis,PCA)的方法,可以将具有多个观测变量的高维数据集降维,使人们可以从事物之间错综复杂的关系中找出一些主要的方面,从而能更加有效地利用大量统计数据进行定量分析,并可以更好地 由于得到协方差矩阵的特征值特征向量有两种方法:特征值分解协方差矩阵、奇异值分解协方差矩阵,所以PCA算法有两种实现方法:基于特征值分解协方差矩阵实现PCA算法、基于SVD分解协方差矩阵实现PCA算法
MQTT与物联网平台(一):基础知识和设备接入物联网平台的实现(以华为云为例)
本文简单介绍了MQTT的基础知识和使用方法,以蓝牙WIFI双模芯片W801作为硬件设备,接入到华为云。
静止无功补偿SVG的基本控制原理
上图是自励单变量控制框图,基本控制方式为,采集计算得到负载无功电流和SVG输出的无功电流的差值,经过PI调节作为功率角δ和固定的调制深度λ和调制波,经过PWM调制形成开关信号驱动SVG的功率电路。该控制方式使保持调制深度λ(即SVG电压的幅度)不变,通过调整δ来调整直流电压和无功,跟踪输出无功功率,直流电压就会大幅度随动,无功相应速度较慢。SVG通常有他励方式和自励方式,他励方式需要提供外部的直流电源,自励方式通过电网输出有功功率至SVG建立SVG的直流电压。δ为Us和Uc之间的相角差。
PCA的Matlab实现与分析
PCA(Principal Component Analysis)在机器学习领域中,是很常见的一种降维的方法。 PCA的主要思想:将原始高维数据集中的点,映射到低维的超平面中,。
C#开发者必备:VSPD虚拟串口快速配置指南(附汉化教程)
本文为C#开发者提供了VSPD虚拟串口的快速配置与汉化教程。详细介绍了如何安装、汉化VSPD,并创建稳定的虚拟串口对,重点讲解了如何将其集成到C#开发工作流中,使用SerialPort类进行数据通信测试、协议模拟及故障排查,有效提升硬件通信开发的效率。
PCA原理分析和Matlab实现方法(三)
PCA主成分分析原理分析和Matlab实现方法(三) PCA算法主要用于降维,就是将样本数据从高维空间投影到低维空间中,并尽可能的在低维空间中表示原始数据。PCA的几何意义可简单解释为: 0维-PCA:将所有样本信息都投影到一个点,因此无法反应样本之间的差异;要想用一个点来尽可能的表示所有样本数据,则这个点必定是样本的均值。 1维-PCA:相当于将所有样本信息向样本均值的直线投影; 2维-PCA:将样本的平面分布看作椭圆形分布,求出椭圆形的长短轴方向,然后将样本信息投
SAP Gateway 中事务码 /IWFND/MAINT_SERVICE 的用法介绍
本文系统梳理了SAP Gateway中/IWFND/MAINT_SERVICE事务码的核心功能与运维实践。作为OData服务管理中樞,它支持服务注册激活、ICF节点配置、系统别名绑定、批量处理等关键操作。文章详解了服务目录、ICF节点、系统别名的配置要点,提供了批量激活、缓存清理、性能监控等实用技巧,并针对常见陷阱(如传输配置、删除残留)给出解决方案。通过制造业批量激活、零售业OAuth集成等案例,展示了事务码在企业级应用中的实际价值,为SAP Gateway运维提供了一套完整的治理清单。
电磁弹射器电源设计参数
电磁弹射器采用中高压直流供电系统(5,000-12,000V DC),以满足航母弹射的高功率需求(单次120+兆焦耳)。典型系统如福特级航母EMALS,峰值功率达100-130MW,工作电压8-10kV DC,通过高压设计降低电流(15-20kA)并提升效率20%。系统包含整流、储能和脉冲逆变环节,电压随载荷动态调整(轻型4-6kV,重型8-12kV)。采用特殊绝缘材料和模块化设计确保安全,相比蒸汽弹射节能30%且控制更精准(误差<±2%)。
matlab 数据pca应用,Matlab – 多维数据的PCA分析与重构
这是一个快速的演练。 首先,我们创build一个隐藏variables(或“因素”)的matrix。 它有100个观测值,有两个独立的因素。>> factors = randn(100, 2);现在创build一个加载matrix。 这将把隐藏的variables映射到你观察到的variables上。 说你观察到的variables有四个特征。 那么你的加载matrix需要是4 x 2...
ShaderJoy —— 简单又神奇的 “合体” 函数【GLSL】
smin 函数 它实际上有两种常见的实现方式 多项式 指数 多项式 smin 函数图 其对应的代码为 float smin( float a, float b ) { // 多项式 const float k = 0.5; float h = clamp(0.5 + 0.5 * (b - a) / k, 0.0, 1.0); return mix(b, a, h) - k * h * (1.0 - h); } 从上图中我们可以很明显的看出有两处不连...
MATLAB实现主成分分析(PCA)
MATLAB实现主成分分析(PCA) 去发现同类优质开源项目:https://gitcode.com/ 资源描述 本资源文件提供了一个基于MATLAB实现的主成分分析(PCA)降维算法。PCA是一种常用的数据降维技术,通过将高维数据投影到低维空间,可以在最小化信息损失的前提下实现数据的压缩。本资源内附完整的MATLAB代码,方便用户直接使用或进行进一步的修改和优化。 功能特点 数据降维:通过PC...
inori mmd 7z
楪祈的模型资源....................................................................................................................................................................................................................
计算机控制技术及应用
《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。
PCA主成分分析的MATLAB和Eigen实现以及应用
PCA实现和应用 PCA理论 计算协方差矩阵 PCA过程 MATLAB实现 求协方差矩阵 PCA过程 Eigen实现 实现效果图 目前在项目中需要对模型的位置进行矫正,想到了使用主成分分析,提取主方向,将模型方向进行变换得到正确的方向。以下对PCA过程首先在matlab中进行实现,然后在C++矩阵库Eigen中实现,总体较为简单。 PCA实现和应用 PCA理论...
温度PID控制PLC程序
温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值
MATLAB实例:PCA(主成成分分析)详解
发现一篇非常好的pca学习文章, 作者:凯鲁嘎吉 - 博客园 MATLAB实例:PCA(主成成分分析)详解 - 凯鲁嘎吉 - 博客园 (cnblogs.com) 1. 主成成分分析 2. MATLAB解释 详细信息请看:Principal component analysis of raw data - mathworks [coeff,score,latent,tsquared,explained,mu] =pca(X) coeff=pca(X)returns the princip...
TMS_WebGMaps_1.9.8.0_Full_Source
TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder
3万+



被折叠的 条评论
为什么被折叠?



