"Misha Koshelev" <mk144210@bcm.edu> wrote in message <gvbvi6$h6g$1@fred.mathworks.com>...
> Hi, I am trying to do one of the following equivalent things (well equivalent for this problem):
>
> 1) I have row vectors
> a = [1;2;3]; b = [4;5;6] and I want to get a (cell?) array like
> {[1 2 3 4] [2 3 4 5] [3 4 5 6]}
> in the fastest possible way without using a for loop?
>
> 2) I have a row vector again
> a = [20; 21; 22; 27; 28; 30; 31; 32; 33];
> And I want to "fill in" the elements in a new row vector so that, let's say, this vector will have all elements from a to a+T. Let's say for T=2 I want:
> newvec = [20; 21; 22; 23; 24; 27; 28; 29; 30; 31; 32; 33; 34; 35].
>
> Now I actually also want to limit the elements that get "expanded" so that we do not go past a module 10 boundary (e.g., 29 will not be expanded; 28 will only be expanded to 29; 27 to 28 and 29; 26 to 27 and 28)...
>
> Thank you for your help.
>
> Misha
Ok, here's something simpler. I want to vectorize something like this:
a = [row vector];
b = [];
for i=1:K
b = union(b,a+i);
end
