Is there a more efficient way to compute this other than using a loop ?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Rayan Glus
am 31 Mai 2021
Kommentiert: Rayan Glus
am 31 Mai 2021
Hello,
Say, vectors a and b have different sizes. I wonder if there is a simpler and more efficient way of writing the lines below.
b = [1 3 4 7 8 10 2 5 6];
a = [2 3 9];
for ii = 1:length(a)
b(b==a(ii))=[];
end
Output:
b = 1 4 7 8 10 5 6
Thanks!
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements 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!