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

 採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 3 月 13 日
編集済み: Azzi Abdelmalek 2013 年 3 月 13 日

0 投票

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

3 件のコメント

M@lik Ali
M@lik Ali 2013 年 3 月 13 日
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 2013 年 3 月 13 日
B(find(all(ismember(B,A),2)),:)=[]
M@lik Ali
M@lik Ali 2013 年 3 月 13 日
thanks second one working gud

サインインしてコメントする。

その他の回答 (1 件)

Andrei Bobrov
Andrei Bobrov 2013 年 3 月 13 日
編集済み: Andrei Bobrov 2013 年 3 月 13 日

1 投票

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,:) = [];

3 件のコメント

M@lik Ali
M@lik Ali 2013 年 3 月 13 日
sorry it is not working
Andrei Bobrov
Andrei Bobrov 2013 年 3 月 13 日
corrected
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 3 月 13 日
This solution is more general

サインインしてコメントする。

カテゴリ

ヘルプ センター および File Exchange で Creating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by