|
On 5/16/2011 12:48 PM, Aron Sceidt wrote:
> Is there an efficient way to build a vector like for example I need four
> 1's after each other, two 2's, seven 4's and three 9's? Something like
> the way we use the colon operator?
>
> [1 1 1 1 2 2 4 4 4 4 4 4 4 9 9 9]
Combinations of repmat(), ones(), etc., can be joined in creative ways... :)
There are other more exotic things that can be used on occasion
depending on the actual pattern(s) needed; what, specifically would be
dependent on those patterns.
[ones(1,4) 2 2 4*ones(1,7) 9 9 9]
is just one obvious of any number of possibilities for the example. One
would presume the number of repetitions and values are programmatically
know; if so, the above could be automated or at least made generic w/
use of variables instead of explicit constants.
--
|