Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
howto create

Subject: howto create

From: Michal Kvasnicka

Date: 30 Oct, 2011 20:35:11

Message: 1 of 3

by simple "one line", but still effective command the following tranformation:

[n1 n2 ... nk] -> [ 1 ... 1 2 ... 2 k ... k]
                          n1 times n2 times nk times

Thanks Michal

Subject: howto create

From: Michal Kvasnicka

Date: 30 Oct, 2011 21:43:10

Message: 2 of 3

"Michal Kvasnicka" wrote in message <j8kcdv$c28$1@newscl01ah.mathworks.com>...
> by simple "one line", but still effective command the following tranformation:
>
> [n1 n2 ... nk] -> [ 1 ... 1 2 ... 2 k ... k]
> n1 times n2 times nk times
>
> Thanks Michal

examples:
[1 1 1] = [ 1 1 1]
[ 1 2] = [ 1 2 2]
[2 1 1] = [1 1 2 3]
etc.

Subject: howto create

From: Bruno Luong

Date: 31 Oct, 2011 07:32:10

Message: 3 of 3

a=[1 2 2 1]

b=cumsum(a)
c=zeros(1,b(end));
c([0 b(1:end-1)]+1)=1;
cumsum(c)

% Bruno

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us