필터 지우기
필터 지우기

Cut a continuous signal into frames

조회 수: 3 (최근 30일)
Yasmin Tamimi
Yasmin Tamimi 2012년 7월 7일
Hey everyone,
I have a continuous signal with size 1x400000 (analog data that corresponds to a 20 min signal) and I would like to frames with 1 min each and do some signal processing on each. I wrote this code and tried it for a small matrix but when I increased the size of my matrix matlab was busy for a very long time. So, what is wrong and what can I do to improve it.
The code: t= [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 17 17.01 17.02 17.03 17.4 18];
for i =1:length(t)
if t(i) <= 17
T(i)= t(i);
else
break;
end
end
plot(T, D(1:length(T))) %matrix D corresponds to the amplitude of my signal
when I used t= [1*ones(1,400000) 17 17 17.01 17.02 17.03 17.4 18] with the same code the program just like hanged!!!!
Any help will be appreciated.
  댓글 수: 4
Yasmin Tamimi
Yasmin Tamimi 2012년 7월 11일
@Luffy Thanx for the code but I want to cut the signal and not introduce zeros!! The plot was wrong,, but thanx anyway.
Yasmin Tamimi
Yasmin Tamimi 2012년 7월 11일
@Image Analyst It is only a number where I want to cut the signal. In my real scenario I want to cut the signal into frames at multiples of 60.

댓글을 달려면 로그인하십시오.

채택된 답변

Wayne King
Wayne King 2012년 7월 7일
편집: Wayne King 2012년 7월 7일
I'm guessing by your description, 400000 samples in 20 minutes that your sampling interval is 3 msec. So I'll use that value which gives 20000 samples in 1 minute.
You can just use reshape()
% just making up some data the length of your signal
x = randn(400000,1);
xnew = reshape(x,20000,20);
Now each column of the matrix xnew is a segment (frame) of your signal 1-minute in length, you can now do your processing on the columns of the matrix.
If you have the Signal Processing Toolbox, see the help for buffer() also, which enables you to do the same thing but works when you want some overlap between the columns, or you do not have exactly the number of samples required for reshape.
  댓글 수: 1
Yasmin Tamimi
Yasmin Tamimi 2012년 7월 11일
편집: Yasmin Tamimi 2012년 7월 11일
Thanx it really helped. I have tried another way:
t(t>60)=[];
As for buffer() i'm still trying it to make it work!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with Signal Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by