Maybe this can help you
%random data with a random number of columns from 10 to 100
a=rand(1,randi([10 100]));
b=rand(1,randi([10 100]));
%find the maximum index that you can go in your window
mx=min(numel(a),numel(b));
%random start index of the window from 1 to the maximum index of data
in=randi([1 mx]);
n=in:mx-1; %index values inside the selected window
%just for fun plot the data inside the window
cla
plot(n,a(n),n,b(n))