You are given a matrix full of numbers who happen to be very shy. Write a MATLAB function that will put a square of zeros around each term in the matrix, thus giving them the privacy and space they desire. This should include a border of zeros around the outside of the matrix.
For example, if your input matrix is magic(3):
[8 1 6 3 5 7 4 9 2]
your output will be:
[0 0 0 0 0 0 0 0 8 0 1 0 6 0 0 0 0 0 0 0 0 0 3 0 5 0 7 0 0 0 0 0 0 0 0 0 4 0 9 0 2 0 0 0 0 0 0 0 0]
Please help them out, but do so quietly; they don't like the attention very much.
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers75
Suggested Problems
-
Find all elements less than 0 or greater than 10 and replace them with NaN
15808 Solvers
-
Return the 3n+1 sequence for n
8513 Solvers
-
Sum of diagonal of a square matrix
1642 Solvers
-
Find the index of the largest value in any vector X=[4,3,4,5,9,12,0,4.....5]
401 Solvers
-
Find Factrorial without using built-in function
138 Solvers
More from this Author80
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
dyadup funciton is not supported?!
I'd never heard of it, but you are correct: it does exactly what this problem asks. It's part of the wavelet toolbox, which I guess isn't included in Cody.