user11158049
user11158049

Reputation:

How to find the elements of an array that are not in another array

I currently have a MATLAB range j=1:200 and an array m=96:106.

I'm trying to define a new array that will have all the values in j that aren't in m.

I've tried using

j_prime = (j~=m) 

but that doesn't work for a range of numbers. If m was just a number like 101, this works. I'm sure I just don't know MATLAB enough to know a good way of doing this.

Upvotes: 0

Views: 67

Answers (1)

user11158049
user11158049

Reputation:

Just found the setdiff command so using setdiff(j,m) will result in what I'm looking for!

Upvotes: 2

Related Questions