m=sum(diag(magic(n)))
This problem could probably be explained a little better.
m= magic_sum(n)
z=magic(n);
m=sum(z(:));
why this aint working
@Anshul, Because here we want the sum of particular row, and your soln defines the sum of all the elements in the matrix!
@harsh thanks
nice question
Good one
function m = magic_sum(n)
x = magic(n);
y = sum(x);
m= randsample(y,1);
end
why it is wrong?
function m = magic_sum(n)
t=magic(n)
m=sum(t(1:n));
end
temp=sum(magic(n),1); m=temp(1);
its hard
First non-zero element in each column
609 Solvers
Back to basics 6 - Column Vector
921 Solvers
Create an index-powered vector
379 Solvers
Find the index of the largest value in any vector X=[4,3,4,5,9,12,0,4.....5]
304 Solvers
Deleting an element in a matrix
332 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!