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
-
Number of odd and even elements within matrix
134 Solvers
-
Create an index-powered vector
490 Solvers
-
588 Solvers
-
898 Solvers
-
construct matrix with identical rows
177 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!