MATLAB: How to find the coordinates of a known vector, within a larger vector

vector coordinates

I'd like to take a group of linear vectors, and find where a smaller known vector is placed within them.
For example if I have:
Vector1 = 3 2 4 1 3 2 4 1 3 2 4 2 4 3 4 3 1 4 2 2 3 4 1 4 2
Vector2 = 1 4 2 3 1 4 2 4 2 3 4 3 1 4 2 2 4 1 3 2 4 1 2 3 1 1 1
Vector3 = 1 4 2 3 4 1 4 2 3 1 4 3 4 3 1 4 2 1 4 2 3 1 4 1 3
Vector4 = 1 3 2 4 2 4 1 4 3 2 3 4 3 1 4 2 1 1 3 2 4 2 4 1 2 3
Vector5 = 1 3 2 4 2 1 1 1 3 4 3 2 3 4 3 1 4 2 1 1 3 2 4 2 4 1 2 3
ConstantVector = 3 4 3 1 4 2
I know that each of the vectors 1-5 have the ConstantVector in them somewhere. I would like to be able to quickly output the position of the vector in each case.
The end aim is to be able to put Vectors 1-5 into a matrix of zeros such the sections denoted by ConstantVector are all aligned in columns. For example the above vectors would become:
3 2 4 1 3 2 4 1 3 2 4 2 4|3 4 3 1 4 2|2 3 4 1 4 2 0 0 0 0 0 0
0 0 0 0 1 4 2 3 1 4 2 4 2|3 4 3 1 4 2|2 4 1 3 2 4 1 2 3 1 1 1
ConstantOverLaying = 0 0 1 4 2 3 4 1 4 2 3 1 4|3 4 3 1 4 2|1 4 2 3 1 4 1 3 0 0 0 0
0 0 0 1 3 2 4 2 4 1 4 3 2|3 4 3 1 4 2|1 1 3 2 4 2 4 1 2 3 0 0
0 1 3 2 4 2 1 1 1 3 4 3 2|3 4 3 1 4 2|1 1 3 2 4 2 4 1 2 3 0 0
I've put lines on either side of the ConstantVector just to show that they overlap.
My current thinking is that once I have the coordinates I can use them to automatically shift them left or right as needed when adding them to the matrix of zeroes. If anyone can think of any better ways to do this it is of course welcome.

Best Answer

You can use strfind:
Vector1 = [3 2 4 1 3 2 4 1 3 2 4 2 4 3 4 3 1 4 2 2 3 4 1 4 2];
Vector2 = [1 4 2 3 1 4 2 4 2 3 4 3 1 4 2 2 4 1 3 2 4 1 2 3 1 1 1];
Vector3 = [1 4 2 3 4 1 4 2 3 1 4 3 4 3 1 4 2 1 4 2 3 1 4 1 3];
Vector4 = [1 3 2 4 2 4 1 4 3 2 3 4 3 1 4 2 1 1 3 2 4 2 4 1 2 3];
Vector5 = [1 3 2 4 2 1 1 1 3 4 3 2 3 4 3 1 4 2 1 1 3 2 4 2 4 1 2 3];
ConstantVector = [3 4 3 1 4 2];
strfind(Vector1,ConstantVector)
if you want all the vectors 1...5 together:
V={Vector1;Vector2;Vector3;Vector4;Vector5};
cellfun(@(x) strfind(x, ConstantVector),V)
Are you able to do the rest on your own? If you need further help, just ask here.