-
2 Comments
Robert Priceon 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 Shingadeon 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.
Suggested Problems
Is my wife right? Now with even more wrong husband
1283 Solvers
417 Solvers
Check if number exists in vector
7284 Solvers
Get the elements of diagonal and antidiagonal for any m-by-n matrix
364 Solvers
Number of Even Elements in Fibonacci Sequence
925 Solvers
More from this Author95
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!