How to map points in Vector A with points in vector B?
3 views (last 30 days)
Show older comments
Hi,
I have two row vectors with the same size.
A = randi(100,1,100);
B = randi([101, 200],1,100);
I want to have another row vector AB where :
AB(i) = j ;% i and j are elements in A and B respectively
AB(j) = i;
AB's length supposed to be length of A + length of B, correct? What if in one case i and j happens to have the same value when both A and B are :
A = randi(100,1,100);
B = randi(100,1,100);
Thanks!
Accepted Answer
Steven Lord
on 10 Mar 2021
So you want something like this?
v = randperm(10) % Shuffle the numbers from 1 to 10
A = v(1:5) % Cut the "deck"
B = v(6:10)
AB = zeros(1, 10);
AB(A) = B;
AB(B) = A
More Answers (0)
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!