How to reduce my sample rate of data

15 visualizaciones (últimos 30 días)
Ali Almakhmari
Ali Almakhmari el 24 de En. de 2024
Editada: Star Strider el 24 de En. de 2024
Just to clarify I dont want to interpolate my data to reduce the sample, I would like to simply reduce it by picking out consecutive data. For example, I have this data variable with two columns and 14821 rows, and I would like to reduce it to 742. Now how I would imagine it is to first pick up the first row and then skip about 20 elements, then pick up the 21st row, then skip 20 elements more, and pick the 41st row and so on and on. And that way we will end up with 742 rows instead of 14821. Knowing that my variable is 14821 and I want to skip 20, I want the output to be my new variable sampled less and most importantly includes the first and last rows of the original data.
Seems like such a simple problem but for the love of pete I couldnt get it to work. Any help is appreciated.

Respuestas (2)

Star Strider
Star Strider el 24 de En. de 2024
Editada: Star Strider el 24 de En. de 2024
Use a colon-operator generated vector with the necessary step.
Example —
A = [1:50; randn(1,50)].'
A = 50×2
1.0000 0.2100 2.0000 0.3274 3.0000 -1.8190 4.0000 -1.2616 5.0000 0.4329 6.0000 -1.7326 7.0000 1.2852 8.0000 1.1994 9.0000 0.6591 10.0000 0.7422
idx5 = 1:5:size(A,1) % 'step' = 5
idx5 = 1×10
1 6 11 16 21 26 31 36 41 46
A_selected = A(idx5,:)
A_selected = 10×2
1.0000 0.2100 6.0000 -1.7326 11.0000 -1.7366 16.0000 0.0235 21.0000 0.8745 26.0000 1.1494 31.0000 -0.4901 36.0000 0.1224 41.0000 -0.3258 46.0000 0.0083
It should be straightforward to adapt this to your problem.
.

Fangjun Jiang
Fangjun Jiang el 24 de En. de 2024
a=[1:14821;rand(1,14821)]';
b=a(1:20:end,:)
b = 742×2
1.0000 0.8423 21.0000 0.2997 41.0000 0.6618 61.0000 0.4014 81.0000 0.7694 101.0000 0.5680 121.0000 0.2974 141.0000 0.7802 161.0000 0.4026 181.0000 0.4821

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by