matlab故障檢測

2022-12-13 07:39:02 字數 4153 閱讀 1405

clc;

global xx_train;

global xx_test;

global f;

%開始xtrain =xx_train;

xtest =xx_test;

% xtrain=dlmread('d00_');

% %xtrain=xtrain';

% xtest=dlmread('d13_');

%標準化處理:

x_mean = mean(xtrain); %按列求xtrain平均值

x_std = std(xtrain); %求標準差

[x_row,x_col] = size(xtrain); %求xtrain行、列數

xtrain=(xtrain-repmat(x_mean,x_row,1))./repmat(x_std,x_row,1); %標準化

%求協方差矩陣

sigmaxtrain = cov(xtrain);

%對協方差矩陣進行特徵分解,lamda為特徵值構成的對角陣,t的列為單位特徵向量,且與lamda中的特徵值一一對應:

[t,lamda] = eig(sigmaxtrain

%取對角元素(結果為一列向量),即lamda值,並上下反轉使其從大到小排列,主元個數初值為1,若累計貢獻率小於90%則增加主元個數

d = flipud(diag(lamda));

cpv=0.95;

num_pc = 1

while sum(d(1:num_pc))/sum(d) < cpv

num_pc = num_pc +1;

end%取與lamda相對應的特徵向量

p = t(:,x_col-num_pc+1:x_col

tt=xtrain*t;

%對資料的降維

tt1=xtrain*p;

%求置信度95%時的t2統計控制限

t2ucl1=num_pc*(x_row-1)*(x_row+1)*finv(0.95,num_pc,x_row - num_pc)/(x_row*(x_row - num_pc));

%置信度為95%的q統計控制限

for i = 1:3

theta(i) = sum((d(num_pc+1:x_col)).^i);

endh0 = 1 - 2*theta(1)*theta(3)/(3*theta(2)^2);

ca = norminv(0.95,0,1);

qucl = theta(1)*(h0*ca*sqrt(2*theta(2))/theta(1) + 1 + theta(2)*h0*(h0 - 1)/theta(1)^2)^(1/h0

%**監測:

n1 = size(xtest,1);

xtest=(xtest-repmat(x_mean,n1,1))./repmat(x_std,n1,1);%標準化處理

%求t2統計量,q統計量

[r,y] = size(p*p');

i = eye(r,y);

t2 = zeros(n1,1);

q = zeros(n1,1);

for i = 1:n1

t2(i)=xtest(i,:)*p*pinv(lamda(x_col-num_pc+1:x_col,x_col-num_pc+1:

x_col))*p'*xtest(i,:)';

q(i) = xtest(i,:)*(i - p*p')*(i - p*p')'*xtest(i

endsprintf(" num_pc:%d\n cpv:%d\n f=[%d ; %d ; %d ; %d ; %d]:

",num_pc,cpv,f(1,1),f(2,1),f(3,1),f(4,1),f(5,1))

%繪圖 figure

subplot(2,1,1);

plot(1:n1,t2,'k');

title('主元分析統計量變化圖');

xlabel('取樣數');

ylabel('t^2');

hold on;

line([0,n1],[t2ucl1,t2ucl1],'linestyle','--','color','r');

subplot(2,1,2);

plot(1:n1,q,'k');

xlabel('取樣數');

ylabel('spe');

hold on;

line([0,n1],[qucl,qucl],'linestyle','--','color','r');

%%figure

s=d';

pareto(s(1,1:3))

clc;

global xx_train;

global xx_test;

global f;

%開始xtrain =xx_train;

xtest =xx_test;

% xtrain=dlmread('d00_');

% %xtrain=xtrain';

% xtest=dlmread('d06_');

%標準化處理:

x_mean = mean(xtrain); %按列求xtrain平均值

x_std = std(xtrain); %求標準差

[x_row,x_col] = size(xtrain); %求xtrain行、列數

xtrain1=(xtrain-repmat(x_mean,x_row,1))./repmat(x_std,x_row,1); %標準化

%視窗大小

windows =100;

xtrain = zeros(x_row-windows+1,x_col);

% 訓練資料視窗化

%加窗處理

for i = windows:1:x_row

for j = 0:1:windows-1

xtrain(i-windows+1,:) = xtrain1(i-j,:) + xtrain(i-windows+1,:);

endendxtrain=xtrain./windows;

[x_row,x_col] = size(xtrain);%重新計算行

%求協方差矩陣

sigmaxtrain = cov(xtrain);

%對協方差矩陣進行特徵分解,lamda為特徵值構成的對角陣,t的列為單位特徵向量,且與lamda中的特徵值一一對應:

[t,lamda] = eig(sigmaxtrain

%取對角元素(結果為一列向量),即lamda值,並上下反轉使其從大到小排列,主元個數初值為1,若累計貢獻率小於90%則增加主元個數

d = flipud(diag(lamda));

cpv=0.85;

num_pc = 1

while sum(d(1:num_pc))/sum(d) < cpv

num_pc = num_pc +1;

end%取與lamda相對應的特徵向量

p = t(:,x_col-num_pc+1:x_col

tt=xtrain*t;

%對資料的降維

tt1=xtrain*p;

%求置信度95%時的t2統計控制限

t2ucl1=num_pc*(x_row-1)*(x_row+1)*finv(0.95,num_pc,x_row - num_pc)/(x_row*(x_row - num_pc));

%置信度為95%的q統計控制限

for i = 1:3

theta(i) = sum((d(num_pc+1:x_col)).^i);

endh0 = 1 - 2*theta(1)*theta(3)/(3*theta(2)^2);

ca = norminv(0.95,0,1);

qucl = theta(1)*(h0*ca*sqrt(2*theta(2))/theta(1) + 1 + theta(2)*h0*(h0 - 1)/theta(1)^2)^(1/h0

%**監測:

%加窗處理

n1 = size(xtest,1);

xtest=(xtest-repmat(x_mean,n1,1))./repmat(x_std,n1,1);%標準化處理

xtest1 = xtest;

xtest = zeros(n1-windows+1,x_col);

for i = windows:1:n1

檢測裝置故障應急預案

xx超限檢測站 為確保不停車檢測系統在檢測過程中執行平穩 道路安全暢通,提高快速處置治超檢測中出現的各類裝置故障,形成快捷反應機制,特制定本預案。一 適用範圍 不能正常進行治超檢測。二 工作原則 統一領導,分級負責,快速反應,保障暢通。三 工作目標 文明執法,保障檢測現場良好的檢測秩序和通行車輛的安...

故障汽車的檢測方法與檢測技術分析

摘要汽車維修與保養是用車過程中最為常見的話題,汽車進入車主的生活以後,用車生活就離不開汽車的維修與保養。汽車雖然不屬於易耗品,但是機械產品都有著這樣的弊端 需要不定期的進行檢查 保養甚至是維修。對於保養以及維修而言,其主要決定條件在於故障汽車的檢測。完善健全的檢測方法可以高效準確的診斷出汽車的故障,...

電氣裝置故障檢測方法

近來,隨著半導體元件效能的提高和以絕緣材料為代表的各種電工材料的發展,促使發電機 變壓器 電動機等電氣裝置朝著小型 大容量的方向發展。而控制裝置卻由於整合化 靜止化 精密化而日趨小型。由於在各個環節上大量採用程式控制器和微處理機,代替了歷來採用的有觸點式繼電器製成的控制盤,從而能進行複雜的控制。因此...