test.m

来自「matlab中噪声模型」· M 代码 · 共 50 行

M
50
字号
addpath '/home/gari/CODE/MATLAB/MODELS/ECGSYN/LATEST-old/'[s ipeaks] = ecgsyn(256,300,0);sampfreq = 256;t=[1/sampfreq:1/sampfreq:length(s)/sampfreq];P = find(ipeaks==1);Q = find(ipeaks==2);R = find(ipeaks==3);S = find(ipeaks==4);T = find(ipeaks==5);Rreal = maxjiggle(s, R', 5);df=(R-Rreal');wrong = find(df>0);plot(t(R(wrong)),s(R(wrong)),'+r');title('ECG (blue) with correctly detected peaks in green, incorrect but close in red')downsample = 1;N_train=300;n_lead=1;downsample=1 wind=0.5; % select the data[train] =  select_train(s, Rreal, N_train, downsample, downsample, wind);dataout= energy_normalise(train);% perform full svd on datapc = svd(dataout);totalEig = sum(pc);% find how many eigenvectors are required to get tmpSum = 0;for (i=1:length(pc))    tmpSum = tmpSum+pc(i);    if (tmpSum<=0.95*totalEig)        eigSig=i;    endend% perform PCA on the matrix of QRS complexes[U S V] = svds(dataout,eigSig);recon=(U*U'*dataout);% plot it allfigure;mesh(dataout);title('Training vectors')figure;mesh(recon);title('Reconstruction of QRS complexes using the first 50 components')

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?