Problem 2234. Find and replace the zero array in a matrix
Find the zero array in the matrix and replace it with average of surrounding (adjacent) arrays.
Example:
A =
3 5 7 90 1
5 1 -1 0 2
1 2 3 4 70
23 1 2 3 5
Output is:
B=23.75;
Solution Stats
Problem Comments
-
5 Comments
Show
2 older comments
Jon
on 4 Mar 2014
What elements do you consider the "surrounding arrays"?
J-G van der Toorn
on 4 Mar 2014
Surrounding arrays apparently are the elements right above, below, left, and right the zero elements. Found out by reverse engineering. The x is still a mystery.
Jean-Marie Sainthillier
on 8 Mar 2014
More tests please. A lot of solutions assume that 0 can't be in the first (or last) column.
Solution Comments
Show commentsProblem Recent Solvers43
Suggested Problems
-
1232 Solvers
-
6677 Solvers
-
Test if a Number is a Palindrome without using any String Operations
238 Solvers
-
We love vectorized solutions. Problem 1 : remove the row average.
835 Solvers
-
Create matrix of replicated elements
383 Solvers
More from this Author2
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!