Clear Filters
Clear Filters

Removing values form the Matrix

3 views (last 30 days)
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

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 13 Mar 2013
Edited: Azzi Abdelmalek 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,:)=[]
  3 Comments
Azzi Abdelmalek
Azzi Abdelmalek on 13 Mar 2013
B(find(all(ismember(B,A),2)),:)=[]
M@lik Ali
M@lik Ali on 13 Mar 2013
thanks second one working gud

Sign in to comment.

More Answers (1)

Andrei Bobrov
Andrei Bobrov on 13 Mar 2013
Edited: Andrei Bobrov on 13 Mar 2013
in your case:
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,:) = [];

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!