2
$\begingroup$

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.

$\endgroup$
2
$\begingroup$

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}

| improve this answer | |
$\endgroup$
  • $\begingroup$ I think for my goal, I must write: Complement[list, Flatten@aA] $\endgroup$ – Unbelievable Jun 3 '14 at 18:11
  • $\begingroup$ @mostafa Oh yes, I didn't read carefully. $\endgroup$ – mfvonh Jun 3 '14 at 18:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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