技术专栏
基于Wi-Fi CSI的摔倒检测(四):CSI数据处理-PCA降维(下)
本篇文章,主要是为上篇文章作补充,给出完整代码即效果。
clear all
clc
csi_trace = read_bf_file('sample_data/lie1.dat');
pac_num=size(csi_trace,1);
subcarrier=zeros(1,990);
Hall=zeros(990,30);
Z=zeros(990,30);
Zk=zeros(990,1);
for j=1:30
for i=1:990;
csi_entry=csi_trace{i};
csi=get_scaled_csi(csi_entry);
csi1=squeeze(csi(1,:,:)).';% 30*3 complex
csiabs=db(abs(csi1));
csiabs=csiabs(:,2);
csi1=csi1(:,2);
subcarrier(i)=csiabs(j);
if(subcarrier(i)>=35)
subcarrier(i)=35;
else if(subcarrier(i)<=1)
subcarrier(i)=1;
end
end
end
yd=wden(subcarrier,'heursure','s','one',10,'sym3');
vs=movvar(yd,50)
figure(1)
subplot(2,1,1);
plot(subcarrier);
title('beforeDWT');
subplot(2,1,2);
plot(yd);
title('afterDWT');
figure(9)
plot(vs);
xlabel('time(s)');
ylabel('variance');
title('movvar_Origin');
hold on
Hall(:,j)=yd.';
end
%uncentralize
for k=1:30
for i=1:990
Zk(i)=Hall(i,k)-mean(Hall(:,k));
end
Z(:,k)=Zk;
end
%Z covariance
C=cov(Z);
% Eigenvector e, eigenvalue R
[E,R]=eig(C);
R=ones(1,30)*R;%The eigenvalues generated by the eig function are transformed into row vectors
TZ_ER=[R;E];
TZ_ER=TZ_ER';
%The eigenvectors are arranged in descending order according to the size of R
TZ_ER=sortrows(TZ_ER,1,'descend');
R=TZ_ER(:,1);%Separating eigenvalues
E=TZ_ER(:,2:end);%Separating eigenvectors
Pca=zeros(30,1);
E=E'
Pca=E(:,1);%chose the 1st pinciple component
Y=Hall*Pca;
res=sum(R(1:2))/sum(R);
apv=movvar(Y',50)
figure(2)
plot(apv,'k','linewidth',3);
xlabel('time(s)');
ylabel('variance');
title('movvar_PCA');
figure(15)
plot (Y,'linewidth',3);
hold on
title('afterPCA');
fprintf('consists the percent\n',res*100);
for i=1:30
plot(Hall(:,i));
end
Butterworth
hfc = 300;
lfc = 0;
fs = 1000;
order = 10;
[b,a] = butter(order, hfc/(fs/2));
figure(5)
freqz(b,a)
noisy_sig = D{7};
dataIn = randn(1000,1);
dataOut = filter(b,a,Y);
figure(6)
subplot(2,1,1)
plot(Y)
hold on
title('original');
subplot(2,1,2)
plot(dataOut);
hold on
title('afterbutterworth');
Y=dataOut;
FFT
F=fft(Y,1024);
figure(9)
plot(abs(F));
axis([0 1800 0 1500]);
STFT
fs = 1000;%
window = 512;
noverlap = window/2;
nfft=1024;
f_len = window/2 + 1;
f = linspace(0, 150e3, f_len);
% s= spectrogram(Y, window, noverlap);
% figure(1);
% imagesc(20*log10((abs(s))));xlabel('Samples'); ylabel('Freqency');
% colorbar;
[s, f, t, p] = spectrogram(Y, window, nfft, f, fs);
figure(8);
imagesc(t, f, p);xlabel('Samples'); ylabel('Freqency');
colorbar;
[s, f, t] = spectrogram(Y, 512,256,f, fs);
figure;
imagesc(t, f, 20*log10((abs(s))));xlabel('Samples'); ylabel('Freqency');
colorbar;
figure(16)
subplot(2,1,1)
spectrogram(Y,128,127,128,fs,'yaxis');
title('STFT');
hold on
[s,f,t,ps]=spectrogram(Y,64,63,64,fs,'yaxis');
m=4:33
n=1:927
pmax=max(ps(m,n),[],1);
subplot(2,1,2)
% % figure(17)
plot(pmax,'linewidth',3,'MarkerEdgeColor','k','MarkerFaceColor','g','MarkerSize',10);
hold on
title('power curve');
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
- 118
- 119
- 120
- 121
- 122
- 123
- 124
- 125
- 126
- 127
- 128
- 129
- 130
- 131
- 132
- 133
- 134
- 135
- 136
- 137
- 138
- 139
- 140
- 141
- 142
- 143
- 144
- 145
- 146
- 147
- 148
- 149
- 150
- 151
- 152
- 153
- 154
- 155
- 156
- 157
<
整段代码效果如下图:
声明:本文内容由易百纳平台入驻作者撰写,文章观点仅代表作者本人,不代表易百纳立场。如有内容侵权或者其他问题,请联系本站进行删除。
红包
85
14
评论
打赏
- 分享
- 举报
评论
3个
手气红包
相关专栏
-
浏览量:17781次2021-01-08 01:48:55
-
浏览量:28123次2021-01-08 11:33:04
-
浏览量:19439次2020-12-21 18:20:26
-
浏览量:33418次2020-12-18 00:01:24
-
浏览量:20980次2020-12-21 18:30:47
-
浏览量:16080次2020-12-19 14:41:57
-
浏览量:6339次2021-01-08 02:27:20
-
浏览量:9834次2020-12-31 13:45:15
-
浏览量:5990次2020-12-29 15:35:42
-
浏览量:5047次2021-08-02 09:33:43
-
浏览量:4997次2021-09-08 09:26:22
-
浏览量:2416次2019-09-16 14:33:10
-
浏览量:1605次2020-02-27 09:14:10
-
浏览量:3521次2019-09-18 22:22:32
-
浏览量:707次2023-12-14 16:51:13
-
浏览量:14917次2021-05-31 17:01:39
-
浏览量:19409次2020-12-31 17:28:23
-
浏览量:14290次2020-12-29 15:13:12
-
浏览量:3021次2019-11-19 14:40:18
置顶时间设置
结束时间
删除原因
-
广告/SPAM
-
恶意灌水
-
违规内容
-
文不对题
-
重复发帖
打赏作者
技术凯
您的支持将鼓励我继续创作!
打赏金额:
¥1

¥5

¥10

¥50

¥100

支付方式:

举报反馈
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明
审核成功
发布时间设置
发布时间:
请选择发布时间设置
是否关联周任务-专栏模块
审核失败
失败原因
请选择失败原因
备注
请输入备注
大神你好,第一张图Magnitude、Phase是什么内容,没找到解释也没在源码中找到对应内容
大神,你好,请问基于Wi-Fi CSI的摔倒检测系列的使用顺序是导入-》相位校准-》预处理-》降噪-》PCA吗?