Removing values form the Matrix

on 13 Mar 2013

Azzi Abdelmalek (view profile)

Hi, All

i have two matrix matrix A has size 2 62 matrix B has size 10 62

actually the matrix B contains also matrix A

i want to remove the matrix A from matrix B.

How i can do this

Products

No products are associated with this question.

Azzi Abdelmalek (view profile)

on 13 Mar 2013
Edited by Azzi Abdelmalek

Azzi Abdelmalek (view profile)

on 13 Mar 2013

for k=1:size(B,1)
if isequal(B(k:k+1,:),A)
idx=k
break
end
end
B(idx:idx+1,:)=[]

M@lik Ali

M@lik Ali (view profile)

on 13 Mar 2013

Thanks for the response,

but i think there must be a simple solution as
for the vector we have
B(ismember(B,A)) = [];
it works for the vector, i think there should be a solution for the matrix
Azzi Abdelmalek

Azzi Abdelmalek (view profile)

on 13 Mar 2013
B(find(all(ismember(B,A),2)),:)=[]
M@lik Ali

M@lik Ali (view profile)

on 13 Mar 2013

thanks second one working gud

Andrei Bobrov (view profile)

on 13 Mar 2013
Edited by Andrei Bobrov

Andrei Bobrov (view profile)

on 13 Mar 2013

B = randi(100,10,62);
A = B(4:5,:);
B(end,:) = A(1,:);     % your data
[a,ii] = ismember(B,A,'rows');
iii = 1:size(A,1);
i1 = strfind(ii(:)',iii) + iii - 1;
B(i1,:) = [];

M@lik Ali

M@lik Ali (view profile)

on 13 Mar 2013

sorry it is not working

Andrei Bobrov

on 13 Mar 2013

corrected

Azzi Abdelmalek

Azzi Abdelmalek (view profile)

on 13 Mar 2013

This solution is more general

Join the 15-year community celebration.

Play games and win prizes!

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi