Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
Need help with a For loop or any loop with some sort for my code
조회 수: 1 (최근 30일)
이전 댓글 표시
I have written a code to calculate an area under a graph( WAV file). But say if the the plot includes 60000 samples I need to calculate the area for every 5000 samples. Currently If "y1" is my data I have a set of data as below:
y = y1(1:5000);
%y = y1(5001:10000);
%y = y1(10001:15000);
%y = y1(15001:20000);
The data from "y" is used to calculate the power spectrum etc. At the moment I have to find "y" manually by Commenting and uncommenting for each line of data, so I was wondering whether anyone could help me out with this situation.
Thanks
댓글 수: 0
답변 (1개)
Wayne King
2012년 4월 26일
If you have the Signal Processing Toolbox, you can use buffer:
y = randn(5e4,1);
y1 = buffer(y,5e3);
Then take your data as the columns of the matrix.
Otherwise, use reshape()
y1 = reshape(y,5e3,10);
I think buffer() might be better, because that handles the case where your data length is not divisible by 5000.
댓글 수: 0
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!