Asked by Todd
on 17 Aug 2012

Right now the left column is time and it counts .01, .02, .03 etc.

I want to pull out all of the data at 5 hz intervals such as 0, .2, .4 and delete the rest of the rows.

I will answer any question for clarification too

Answer by Azzi Abdelmalek
on 17 Aug 2012

Edited by Azzi Abdelmalek
on 17 Aug 2012

fe=100 %sample frequency

te=1/fe %sample time

t=0:te:1;y=rand(length(t),1)%

fd=5 %desired frequency

td=1/fd %desired sample time

nt=floor(td/te)

ind=1:nt:length(t);

new_t=t(ind);

new_y=y(ind);

plot(t,y);hold on;plot(new_t,new_y,'xr','linewidth',14);

Sign in to comment.

Answer by Loginatorist
on 17 Aug 2012

Here is another example. You say the first column is time, so it is here.

% Original data with columns: [time,signal]

S = [(0:.01:2*pi).' sin(0:.01:2*pi).'];

Sd = S(1:20:end,:); % Downsampled signal.

plot(S(:,1),S(:,2),'b.',Sd(:,1),Sd(:,2),'sr')

legend('Original','Downsampled')

Sign in to comment.

Answer by Dr. Seis
on 17 Aug 2012

Edited by Dr. Seis
on 17 Aug 2012

Use resample - This is an example of why you may not want to take every Nth amplitude:

Example where a is your input dataset and b is your output dataset:

Fs_in = 100; % samples per second

Fs_out = 5; % samples per second

b = resample(a,Fs_out,Fs_in);

Sign in to comment.

Opportunities for recent engineering grads.

Apply Today
## 4 Comments

## Jürgen (view profile)

Direct link to this comment:https://de.mathworks.com/matlabcentral/answers/46212-i-have-a-rather-large-matrix-the-data-was-sampled-at-100-hz-i-want-to-the-data-to-look-like-it-wa#comment_94933

## Jürgen (view profile)

Direct link to this comment:https://de.mathworks.com/matlabcentral/answers/46212-i-have-a-rather-large-matrix-the-data-was-sampled-at-100-hz-i-want-to-the-data-to-look-like-it-wa#comment_94934

## Azzi Abdelmalek (view profile)

Direct link to this comment:https://de.mathworks.com/matlabcentral/answers/46212-i-have-a-rather-large-matrix-the-data-was-sampled-at-100-hz-i-want-to-the-data-to-look-like-it-wa#comment_94937

## Jürgen (view profile)

Direct link to this comment:https://de.mathworks.com/matlabcentral/answers/46212-i-have-a-rather-large-matrix-the-data-was-sampled-at-100-hz-i-want-to-the-data-to-look-like-it-wa#comment_95060

Sign in to comment.