i want vector which is long size and each time size change but pattren is same in putting value

1 view (last 30 days)
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 Comments
Jan
Jan on 18 Dec 2016
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 on 19 Dec 2016
Edited: Pratik Anandpara on 19 Dec 2016
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

Sign in to comment.

Answers (1)

Roger Stafford
Roger Stafford on 18 Dec 2016
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;

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!