Block average - MATLAB Cody - MATLAB Central

Problem 42856. Block average

Difficulty:Rate

Given a matrix, calculate the block average of each disjoint sub-matrix of the same size. Assume that the size of the matrix along each dimension is an integer multiple of the size of the sub-matrix along the same dimension.

  • Input: matrix A and the size of each sub-matrix subsz
  • Output: B = blkavg(A,subsz)

Example:

    A = [2  0  1  3  5  7];
    subsz = [1  2];
    B = [1  2  6];

Hint: this is related to Problem 42854. Crunch that matrix!.

Next problem: Problem 42858. Block average ignoring NaN values

Solution Stats

58.59% Correct | 41.41% Incorrect
Last Solution submitted on Jan 07, 2025

Problem Comments

Solution Comments

Show comments
PIVlab surpasses 100K all-time File Exchange downloads
During the past twelve months, PIVlab, a MATLAB Community Toolbox for particle...
4
8
LLMs with MATLAB updated to support the latest OpenAI Models
Large Languge model with MATLAB, a free add-on that lets you access...
2
4

Problem Recent Solvers43

Suggested Problems

More from this Author29

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!