You can do this quite easily with linear indexing, you don't even need reshape!
[r, c] = size(m);
m(1:c:end) = 1;
m =
1 2 3
4 1 6
7 8 1
1 11 12
13 1 15
If r < c
, this is the best I got:
if r < c
n = m';
n(1:r:end) = 1;
m = n';
else
m(1:c:end) = 1;
end