matrix generation 1 to n*n or interval
2 次查看(过去 30 天)
显示 更早的评论
hi guys i have a problem.. how can i generate a matrix n*n with 1 to n*n elements or any other interval? like for a 3x3 1 2 3 ; 4 5 6 ; 7 8 9 ( i don't want to type it directly i want to generate it knowing n ). Thank you.
0 个评论
采纳的回答
Jos (10584)
2014-3-18
reshape(1:n^2,n,n).'
2 个评论
Jos (10584)
2014-3-18
You might also take a look at this function which I submitted over 8 years ago on the File Exchange:
out = slm(n).'
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!