i want vector which is long size and each time size change but pattren is same in putting value
1 次查看(过去 30 天)
显示 更早的评论
vector like this....i want in this sequence..this is for 1 to 8 row
=[ 2 1 4 3 6 5 8 7
3 1 5 3 7 5 1 7
4 1 6 3 8 5 2 7
5 1 7 3 1 5 3 7
6 1 8 3 2 5 4 7
7 1 1 3 3 5 5 7
8 1 2 3 4 5 6 7]
if size is increase than row change but sequence is same if 12 row than vector = [
2 1 4 3 6 5 8 7 10 9 12 11
3 1 5 3 7 5 9 7 11 9 1 11
4 1 6 3 8 5 10 7 12 9 2 11
5 1 7 3 9 5 11 7 1 9 3 11...............]
sequence is odd term remain same but even number move forward in sequence
4 个评论
Jan
2016-12-18
This is a strange question. I do not have any idea about what you are searching for. What are the inputs, what is variable and what is fixed, and what do you want as output?
回答(1 个)
Roger Stafford
2016-12-18
Let your resulting matrix, M, have m rows and n columns.
b = mod(0:n-1,2)==0;
M = repmat((1:n).*b+(-1:n-2).*(~b),m,1);
M = mod(M+bsxfun(@times,(0:m-1).',b),n)+1;
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!