Hey again I want function that gives matrix C from A and B thanks
in fact if we have the same raw in A and B , we delete it and the result will be the matrix C

6 件のコメント

Image Analyst
Image Analyst 2014 年 5 月 30 日
So? Do you have a question?
Geoff Hayes
Geoff Hayes 2014 年 5 月 30 日
A little more detail is required...how is C to be constructed from A and B?
Firas
Firas 2014 年 5 月 30 日
in fact if we have the same raw in A and B , we delete it and the result will be the matrix C
Geoff Hayes
Geoff Hayes 2014 年 5 月 30 日
So is your algorithm to find all rows that are distinct in A and B, assuming that A and B have the same number of columns?
Firas
Firas 2014 年 5 月 30 日
yes
Image Analyst
Image Analyst 2014 年 5 月 30 日
firas, it's like pulling teeth to get you to help us help you. I mean, most people would give example arrays for A, B, and C . Sure I can make up something, but why are you putting the burden on us? Why not make it EASY for us to help you ? Here, read this and then fix your post: http://www.mathworks.com/matlabcentral/answers/6200-tutorial-how-to-ask-a-question-on-answers-and-get-a-fast-answer

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

 採用された回答

Geoff Hayes
Geoff Hayes 2014 年 5 月 30 日
編集済み: Geoff Hayes 2014 年 5 月 30 日

0 投票

If your algorithm is to remove all rows that are common to A and B, and we are assuming that these two matrices have the same number of columns, then try the following:
A = [1 2 3; 4 5 6; 7 8 9; 10 20 30];
B = [11 12 13; 4 5 6; 14 15 16; 7 8 9; 17 18 19];
if size(A,2)==size(B,2)
% get the intersection of A and B, i.e. all those rows that are common
[Rows,IA,IB] = intersect(A,B,'rows');
% Rows is a matrix of the rows common to A and B
% IA is all the row numbers in A of those common rows
% IB is all the row numbers in B of those common rows
% remove all those common rows from A and B
A(IA,:) = [];
B(IB,:) = [];
% concatenate what is left to get C
C = [A;B];
end

1 件のコメント

Firas
Firas 2014 年 5 月 30 日
thank you , it s working

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

その他の回答 (1 件)

Sean de Wolski
Sean de Wolski 2014 年 5 月 30 日
編集済み: Sean de Wolski 2014 年 5 月 30 日

0 投票

Or use setxor
>> C = setxor(A,B,'rows')

カテゴリ

質問済み:

2014 年 5 月 30 日

編集済み:

2014 年 5 月 30 日

Community Treasure Hunt

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

Start Hunting!

Translated by