I\'m developing a program with MatLab that calculates powers of numbers, adds them together, and then sees if any of the first set of numbers (numbers to powers) equals any of t
Example vectors:
>> m = [1 3 5 9]; n = [5 2 1 4 8];
To check if each element of vector m is in n, use ismember:
m
n
>>ismember(m,n) ans = 1 0 1 0
To get the values, not the indices: use logical indexing on m:
>> m(ismember(m,n)) ans = 1 5
or directly use intersect:
>> intersect(m,n) ans = 1 5