Asked by jawad
on 27 Jun 2013

Write a function named blocks that takes two positive integers, n and m, as input arguments (the function does not have to check the format of the input) and returns one matrix as an output argument. The function needs to return a 2n-by-2m matrix where the upper right and lower left n-by m sub matrices are all zeros and the rest of the matrix are all ones.

*No products are associated with this question.*

Answer by Andrei Bobrov
on 27 Jun 2013

Edited by Andrei Bobrov
on 27 Jun 2013

Accepted answer

jawad
on 27 Jun 2013

Andrei Bobrov
on 4 Jul 2013

n = 5; m = 3; out = zeros([n m]*2); for jj = 1:2 out((jj-1)*n+(1:n),(jj-1)*m+(1:m)) = 1; end

Opportunities for recent engineering grads.

## 0 Comments