How can I extract from a table 1 value each 5 or each 10?

2 views (last 30 days)
I'm new to matlab, I'd like to know how to extract a value from a table every 5 or 10, and in doing so create a new table 5 times or 10 times smaller.
(I have some measures taken with a rate too high).
Thank you in advance guys!!

Accepted Answer

the cyclist
the cyclist on 13 Oct 2014
A = rand(100,1);
A_smaller = A(1:5:end)
If you mean something else than this regular sampling, please a lot more detail (and perhaps a small example) of what you mean.

More Answers (1)

Stephen23
Stephen23 on 13 Oct 2014
Edited: Stephen23 on 13 Oct 2014
If you are looking at reducing the data set, here are two common options:
Here we define some fake data for the examples:
>> A = [1:5;6:10]
A =
1 2 3 4 5
6 7 8 9 10
Subsampling in MATLAB is easy using indexing, eg to take every second column of a matrix:
>> A(:,1:2:end)
ans =
1 3 5
6 8 10
Interpolation can be achieved using linear, cubic, or spline interpolation, eg:
>> interp1(A.',1.5:4.5).'
ans =
1.5 2.5 3.5 4.5
6.5 7.5 8.5 9.5

Categories

Find more on Interpolation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!