i got 450082 number or data. To process the data i need to make sampling rate to separated that data in a frame. how to process that data in every frame?
1 次查看(过去 30 天)
显示 更早的评论
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/149876/image.png)
2 个评论
Guillaume
2015-10-8
The question body is just an image with no explanation.
the question title is really not clear. What exactly are you asking?
Note that
>>rem(450082, 256)
ans =
34
450082 is not a multiple of 256. Whatever your question is, you need to explain what you're planning to do with the 34 elements left over.
采纳的回答
Thorsten
2015-10-8
for i = 1:256:numel(z)
zi = z(i:i+255); % get the i'th chunk of 256 values
% do some sample computations on zi
dzi = diff(zi); % difference between successive values of z
m(i)= mean(zi);
md(i) = mean(dzi); % average difference between successive values of z
end
1 个评论
Guillaume
2015-10-8
z(i:i+255)
This fill fail for the last frame which is only 34 elements long.
更多回答(2 个)
Eng. Fredius Magige
2015-10-8
编辑:Eng. Fredius Magige
2015-10-8
Hi Your subframe, say A, are all uniformity 256 for n=1:450082/256 process whatever your requirement in each subframe as calling function: for nn=n:nnn end end
Guillaume
2015-10-8
There are many ways to do split your data into frames of size 256. Which one is best probably depends on what you want to do with the frames.
What you still haven't explained is what you're planning to do with the leftover 34 elements.
Starting point:
waveheights = randi([1 100], 1, 450082); %input wave height
processingfun = @(frame) disp(frame); %some processing function
Option 1: split the data into a cell array, use cellfun (or a for loop) for further processing. The 34 leftover are a slight additional hurdle
splits = [ones(1, floor(numel(waveheights)/256))*256, rem(numel(waveheights), 256)];
waveframes = mat2cell(waveheights, 1, splits);
cellfun(processingfun, waveframes);
Option 2: reshape the data into a matrix. The 34 leftover have to be removed
waveheightshort = waveheights(1:end-rem(end, 256); %remove leftovers
waveframes = reshape(waveheightshort, 256, []); %each columne of waveframe is a frame
for frame = 1:size(waveframes, 2)
processingfun(waveframe(:, frame));
end
Option 3: just use loops.
for frame = 1:256:numel(waveheigts)
waveframe = waveheigt(frame:min(frame+255, end));
processingfun(waveframe);
end
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!