Subtraction for Matrix of Different Length
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
RDG
am 28 Okt. 2013
Bearbeitet: Andrei Bobrov
am 28 Okt. 2013
x=[19 6 7; 45 9 11; 1 4 3; 9 7 6; 4 3 7; 44 1 7];
y=[1 4 3; 9 7 6];
How can I compute x-y?
The remains would be:
remains=[19 6 7; 45 9 11; 4 3 7; 44 1 7]
Thanks in advance.
0 Kommentare
Akzeptierte Antwort
Andrei Bobrov
am 28 Okt. 2013
Bearbeitet: Andrei Bobrov
am 28 Okt. 2013
[a,b] = setdiff(x,y,'rows');
[~,ii] = sort(b);
out = a(ii,:);
or
lb = ismember(x,y,'rows');
out = x(~lb,:);
0 Kommentare
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!