Create block matrix of integers (j+k-1) - Part II - MATLAB Cody - MATLAB Central

Problem 55260. Create block matrix of integers (j+k-1) - Part II

Difficulty:Rate
Given m, n, p, and q, create an m-by-n matrix made up of submatrices, each sized p-by-q (if possible - the last row and column of blocks may be smaller). The elements of the (j,k)th block all have the same value: (j+k-1).
For example, if m = 4, n = 7, p = 2, and q = 3, the matrix is:
A 4-by-7 matrix with each 2-by-3 block shaded a different color. The overall dimensions (m = 4, n = 7) of the matrix are noted. The 2-by-3 (p-by-q) size of each block is also noted.
You can assume m, n, p, and q are all positive integers. (They can have the value 1, however.) As in the illustration above, m may or may not be divisible by p, and n may or may not be divisible by q. It is even possible for m < p or n < q. The resulting matrix will always be m-by-n.

Solution Stats

56.25% Correct | 43.75% Incorrect
Last Solution submitted on Feb 23, 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

Problem Recent Solvers88

Suggested Problems

More from this Author22

Problem Tags

Community Treasure Hunt

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

Start Hunting!