Scanning an entire table in blocks of 60s for max and min values
2 views (last 30 days)
Show older comments
a={rand(1877958,7); rand(1251972,7)};
b=cellfun(@(x) [x; repmat(x(end,:),-mod(size(x,1),-60),1)],a,'un',0)
for i=1:length(b)
mn(i)={max(reshape(b{i}(:,4),60,[])).'};
mx(i)={min(reshape(b{i}(:,5),60,[])).'};
end
Some good people on this forum gave me this code. This code allows the data to be grouped into rows of 60s and then find the max and min value. This code starts at row 1 to 60, 61 to 120, 121 to 180 and so on.
I want the cell array to be expanded and also look at: max and min value of rows 2 to 61, 62 to 121 and so on. max and min value of rows 3 to 62, 63 to 121 and so on. ... max and min value of rows 58 to 117, 118 to 177 and so on. max and min value of rows 59 to 118, 119 to 178 and so on. max and min value of rows 60 to 119, 120 to 179 and so on. STOP
How can I add this expansion to this code? Any help is very much appreciated.
0 Comments
Accepted Answer
Star Strider
on 9 Nov 2014
For example, this code shifts ‘A’ one row up, so that row #2 becomes row #1 after the shift, and so with the others. Note that the top row wraps to the bottom row with each shift, so you will have to take this into account when you write your code.
A = reshape([1:20],4,[])';
B = circshift(A, [-1 0]);
4 Comments
Star Strider
on 9 Nov 2014
Probably the easiest would be to change the circshift call to:
c = circshift(b{i}, [-(k-1) 0]);
leaving the rest unchanged.
More Answers (0)
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!