This solution is outdated. To rescore this solution, sign in.
-
1 Comment
Shizun Li
on 31 Oct 2018
Check this out.
function b = back_and_forth(n)
b=1:n^2;
b=reshape(b,n,n)';
for i=2:2:n
b(i,:)=fliplr(b(i,:));
end
end
Suggested Problems
-
1027 Solvers
-
17191 Solvers
-
Getting the indices from a vector
10376 Solvers
-
Replace multiples of 5 with NaN
449 Solvers
-
Find the index of the largest value in any vector X=[4,3,4,5,9,12,0,4.....5]
382 Solvers
More from this Author96
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!