How to extract column in particular interval from original matrix and to form new matrix?
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Mathieu NOE
el 28 de Abr. de 2022
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 comentarios
Ver también
Categorías
Más información sobre Annotations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!