Problem 42456. Create an array (n,n) where only diagonal elements are '1' and others are '0'
Solution Stats
Solution Comments
-
2 Comments
Anupam Agarwal
on 11 Jul 2015
if mod(x,2)==0
a = eye(x);
b = fliplr(a);
c= a+b;
else
a = eye(x);
b = fliplr(a);
c= a+b;
c(round(x/2),round(x/2)) = 1;
end
I am getting the right solution on software ... here it is failing ... please help me
Jan Orwat
on 11 Jul 2015
solution is in c, output is in y which doesn't exist in workspace.
Problem Recent Solvers78
Suggested Problems
-
243 Solvers
-
Returning a "greater than" vector
235 Solvers
-
641 Solvers
-
253 Solvers
-
515 Solvers
More from this Author1
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!