Problem 1852. Repeat middle rows and columns of an array
Given an MxN numeric array (A), return an array (B) in which the middle rows and columns have each been repeated once. It may be easier to think of this problem as two operations: (1) repeat the middle rows, and then (2) repeat the middle columns.
The motivation for this problem is to create an array that, when used in blockproc(B,[2 2],fun), effectively incorporates a sliding window with 50% overlap. (NOTE: yes, nlfilter will work on array A, but it requires that the processing output be a scalar, whereas blockproc does not)
You may assume that M>1, N>1 (i.e. no scalars or vectors).
Example
If
A = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16]
Then
B = [1 2 2 3 3 4 5 6 6 7 7 8 5 6 6 7 7 8 9 10 10 11 11 12 9 10 10 11 11 12 13 14 14 15 15 16]
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers32
Suggested Problems
-
Find the alphabetic word product
3250 Solvers
-
Find state names that start with the letter N
1176 Solvers
-
Arrange Vector in descending order
10531 Solvers
-
Back to basics 8 - Matrix Diagonals
910 Solvers
-
Matrix indexing with two vectors of indices
709 Solvers
More from this Author44
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!