How to extract column in particular interval from original matrix and to form new matrix?
8 ビュー (過去 30 日間)
古いコメントを表示
i have matrix of size 35040x1. I want to extract the column in the interval of 4.(1,5,9,13 etc..). when i used for loop, it overriding column every iteration. but i need to store column extracted in each iteration to stored in new matrix. could you please point out where done mistake in below coding? thanks in advance.
have tried this code:
L4 = L3(:,1:4:end);
Where L3 is the orginal matrix with size 35040x1.
4 件のコメント
回答 (1 件)
Mathieu NOE
2022 年 4 月 28 日
hello
I guess you mean you want to downsample your data by a factor 4 ; you can of course simply pick one every four sample , but a more "scientific" downsampling approach requires first to apply a low pass filter like decimate does
the result may differ depending of the spectral content of your data
a low frequency sine wave will give similar results by both methods
% case 1 : low frequency sine wave
n = 35040;
L3 = sin((1:n)'*0.001)+0.1*randn(n,1);
L4 = L3(1:4:end);
L5 = decimate(L3,4);
plot((1:n),L3,'b',(1:4:n),L4,'r',(1:4:n),L5,'g');
legend('original','pick 1 of 4','downsampled factor 4');
but a random signal (white noise) which has constant energy from 0 to Nyquist frequency will give quite different outputs . This is because when you simply pick one of four samples you have spectral folding after your "crude" decimation; low pass filtering is needed here !
% case 2 : random noise (white noise)
n = 35040;
L3 = rand(n,1);
L4 = L3(1:4:end);
L5 = decimate(L3,4);
plot((1:n),L3,'b',(1:4:n),L4,'r',(1:4:n),L5,'g');
legend('original','pick 1 of 4','downsampled factor 4');
xlim([0 200])
first 200 samples plot for clarity :
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Annotations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!