I have a rather large matrix. The data was sampled at 100 Hz. I want to the data to look like it was sampled at 5 Hz
古いコメントを表示
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
4 件のコメント
Jürgen
2012 年 8 月 17 日
did you ask the same question before ? I already proposed and answer and there was even a more elaborate answer by somebody else
Jürgen
2012 年 8 月 17 日
by the way , I don't know what the goal is but if you have been oversampling maybe it is better to take the mean of the moving average, depending on your data averaging will probaly decrease noise
Azzi Abdelmalek
2012 年 8 月 17 日
Jürgen, then you are changing your signal
Jürgen
2012 年 8 月 18 日
yeah all right all depends on what you are measuring and the first thing to do is to analyse your data in a smart way of course, but let us say that you are doing e.g. loadcell measurements over time to see how a the force changes, you will have noise on the measurement and the average will gie you an idea how the signal moves in time , that is what I meant
回答 (4 件)
Jürgen
2012 年 8 月 17 日
0 投票
well If I understand it well you have a vector Sample100 with 100 Hz Samples and you want only the sample @ 5 hz Sample5=Sample100(1:20:end) should do the trick then hope this helps regards,J
Azzi Abdelmalek
2012 年 8 月 17 日
編集済み: Azzi Abdelmalek
2012 年 8 月 17 日
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);

Matt Fig
2012 年 8 月 17 日
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')
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);
カテゴリ
ヘルプ センター および File Exchange で Multirate Signal Processing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!