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
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?
Pratik Anandpara
Pratik Anandpara 2016-12-19
编辑:Pratik Anandpara 2016-12-19
example : input is take digit from 1 to 8 output is vector in this pattern
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
here observe one pattern digit is reurn in that pattern 2nd-4th-6th-8th digit remain same and other numbers are in sequence..2nd-4th-6th-8th digit remian same at its place other digit move in sequence from 1 to 8... observe 1st digit-3rd-5th-7th digit in each row it rotate in sequence column wise....but 2nd-4th-6th-8th digit in each row is remain same... observe pls

请先登录,再进行评论。

回答(1 个)

Roger Stafford
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;

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by