how can I create a new array with same data as existing array and in specific order ?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
ME
am 15 Apr. 2015
Beantwortet: Star Strider
am 15 Apr. 2015
i have two arrays.
a = [1,2,3,4,5];
b = [6,1,7,3,5];
I want to be able to create another array called 'c' which contains everything a has but in the order it appears in 'b'. so c should look like: -
c = [1,3,5];
0 Kommentare
Akzeptierte Antwort
Star Strider
am 15 Apr. 2015
This works in the more general situation:
a = randi(10, 1, 5);
b = randi(10, 1, 5);
[C,ia,ib] = intersect(a,b);
c = b(sort(ib))
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Elementary Math finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!