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 Solvers71
Suggested Problems
-
252 Solvers
-
1124 Solvers
-
589 Solvers
-
260 Solvers
-
Determine if input is divisible by three.
187 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!