how to create this vector?

2 views (last 30 days)
benghenia aek
benghenia aek on 30 Jan 2019
Edited: James Tursa on 30 Jan 2019
i have two vectors X and Y:
X=[0 0 0 1 1 1 1 0 0 1 1 0 0 0 1 1 1 1]
Y=[3 6 5]
i want to creat vector Z
Z=[0 0 0 3 3 3 3 0 0 6 6 0 0 0 5 5 5 5]
  4 Comments

Sign in to comment.

Accepted Answer

Andrei Bobrov
Andrei Bobrov on 30 Jan 2019
X=[0 0 0 1 1 1 1 0 0 1 1 0 0 0 1 1 1 1];
Y=[3 6 5];
Y2 = [0,Y];
out = Y2(bwlabel(X) + 1);
  1 Comment
benghenia aek
benghenia aek on 30 Jan 2019
Andrei Bobrov thank you very much for your answere

Sign in to comment.

More Answers (0)

Tags

No tags entered yet.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!