フィルターのクリア

Removing values from a variable.

9 ビュー (過去 30 日間)
RDG
RDG 2014 年 5 月 19 日
編集済み: Jos (10584) 2014 年 5 月 20 日
I need some help. I can't seem to get the result for the following:-
Suppose, I have the following cell array:
A{1}=[1 2 2; 2 2 2; 3 1 2; 4 5 6; 5 5 6; 7 1 2] %Remove value of 4 5 6 and 5 5 6 based on Variable B's second and third column
B{1}=[4 5 6]
How can I remove the value of 4 5 6 and 5 5 6 in A, based on B's second and third column?
My resultant, should be [1 2 2; 2 2 2; 3 1 2; 7 1 2]
Many thanks in advance.

回答 (2 件)

Douglas Alves
Douglas Alves 2014 年 5 月 19 日
編集済み: Douglas Alves 2014 年 5 月 19 日
A{1}=[1 2 2; 2 2 2; 3 1 2; 4 5 6; 5 5 6; 7 1 2] ;
A{1}(4:5,:) = [] ;
it means access the first element of cell 1 (which is a matrix). in parenthesis access the rows 4 and 5 no matter the columns... equal it to []

Jos (10584)
Jos (10584) 2014 年 5 月 19 日
編集済み: Jos (10584) 2014 年 5 月 20 日
What are the exact criteria for removal? Just when the second column of A{1} matches the second value of B{1} and the third column of A{1} matches the third value of B{1}?
And why do you store them as an element of a cell array
A = [1 2 2; 2 2 2; 3 1 2; 4 5 6; 5 5 6; 7 1 2]
B = [4 5 6]
tf = A(:,2)==B(2) & A(:,3)==B(3) % select
A(tf,:) = [] % remove

カテゴリ

Help Center および File ExchangeData Types についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by