This solution is outdated. To rescore this solution, sign in.
-
2 Comments
Robert Price
on 1 Feb 2016
function a = tests(n)
a = ones(n);
a(2:2:numel(a)) = 0;
end
Any ideas why this only works on matreices with an odd number of rows/columns? On the even matrices it changes entire rows to 0's or 1's
Rohan Shingade
on 27 Feb 2016
the ones and zeroes should be alternate whatever their position be. In even columns/rows the element a(1,1) and a(1,2) both remain the same i.e. 1 and 1 so it doesn't work for even number of columns\rows.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!