Home > Archive > Matlab > June 2007 > How do create a unbalanced vector based on a balanced vecto
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
How do create a unbalanced vector based on a balanced vecto
|
|
| Marcos 2007-06-30, 7:12 pm |
| hi,
my problem is this: i have a sequence of 1 and -1, I want to expand
this copying each position several times, but the lengths wil be
diferent like this: 1 -> 9 and -1->7, an example:
original vector: [1 -1 1]
modified: [1 1 1 1 1 1 1 1 1 -1 -1 -1 -1 -1 -1 -1 1 1 1 1 1 1 1 1 1]
can you help me??
thanks
Marcos
| |
|
| Marcos:
<SNIP rle-evergreen...
> original vector: [1 -1 1]
> modified: [9*1 7*-1 9*1]
one of the many solutions
% download <rude> from the fex
<http://www.mathworks.com/matlabcent...objectType=FILE>
% apply it to your data, eg
val=[1,-1,1];
len=val;
len(val==1)=9;
len(val==-1)=7;
v=rude(len,val)
us
|
|
|
|
|