Problem 2063. A matrix of extroverts

Now that the introverts have had their script, the extroverts spoke up (naturally!) and demanded one as well. You will be given a matrix. Write a MATLAB script to output a new matrix consisting of the average of all four terms that are next to each other.

If your input is magic(3)

     8     1     6
     3     5     7
     4     9     2

Your output will be:

4.2500    4.7500
5.2500    5.7500

The top left term (4.25) is the average of [8 1 ; 3 5]. The bottom left term is the average of [3 5 ; 4 9], and so on. You can assume that the size of each of these matrices will be at least 2x2. Good luck!

Solution Stats

82.19% Correct | 17.81% Incorrect
Last solution submitted on Aug 23, 2017

Problem Comments

Solution Comments

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!