Clear Filters
Clear Filters

change position values between two vectors

1 view (last 30 days)
Dear all; I have two vectors as seen below , and I want change position between them depend on vector b. The results should be: a=[73 312 135 192 0 122]; b=[2 1 5 4 6 3];
result=[ 312 73 0 192 122 135];
I tried result(b) = a; % and not work.
please help and Thanks in advance.

Accepted Answer

Star Strider
Star Strider on 25 Dec 2016
This works:
a=[73 312 135 192 0 122];
b=[2 1 5 4 6 3];
Result = a(b)
  2 Comments
skysky2000
skysky2000 on 25 Dec 2016
Thanks alot Star Strider, its work, that really what I want.

Sign in to comment.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!