List(Vecor) Generation
显示 更早的评论
Can I generate list [1 2 3 2 3 4 3 4 5 4 5 6 ....] without for loop?
Thanks!
采纳的回答
更多回答(2 个)
Andrei Bobrov
2019-9-8
编辑:Andrei Bobrov
2019-9-8
m=3;
n=4;
T = 1:m*n;
out = ceil(T/m) + mod(T-1,m);
or
out = floor(T/n) + mod(T-1,m) + 1;
or
out = repmat(1:m,1,n) + repelem(0:n-1,m);
类别
在 帮助中心 和 File Exchange 中查找有关 MATLAB Classes 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!