Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In a matrix, there are some non-zero elements same as: aA=

enter image description here

Also, there is a list such as:

list = {a, b, c, d, e, f, g, ii, jj, kk};

I want to access to elements of the list which are not in the matrix. (I mean: 'c','d','g','jj') I use Complement to this work:

Complement[aA, list]

But Complement doesn't work.

share|improve this question
up vote 2 down vote accepted

Flatten the matrix first.

aA = {{a, b, 0}, {e, f, 0}, {ii, 0, kk}};
list = {a, b, c, d, e, f, g, ii, jj, kk};
Complement[list, Flatten@aA]

{c, d, g, jj}

share|improve this answer
    
I think for my goal, I must write: Complement[list, Flatten@aA] – Unbelievable Jun 3 '14 at 18:11
    
@mostafa Oh yes, I didn't read carefully. – mfvonh Jun 3 '14 at 18:14
    
thank you so much – Unbelievable Jun 3 '14 at 18:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.