## find missing elements in a matrix

### Rashmil Dahanayake (view profile)

on 19 Sep 2014
Latest activity Commented on by Rashmil Dahanayake

on 23 Sep 2014

### Stephen Cobeldick (view profile)

Hi, I have a matrix represents code numbers.
A=[1 2 3 6 7 45 46 47 53 78 80];
B=[55.23 ,74.22]; % B is if same length of A, and contains element by element corresponding data
Say the numbers should be in the range 1:80.
How can I find the numbers which are missing in A.
eg in above case, the expected answer is missing=[4 5 8 9 ... 79]
Then to print a text file
experiment 1 results 55.23
experiment 2 results 442.23
experiment 4 data missing
.
.
experiment 79 data missing
experiment 80 results 442.2

Stephen Cobeldick

### Stephen Cobeldick (view profile)

on 19 Sep 2014
• A separate topic.
• Easy to solve yourself using any search engine.
Other users here are not paid to write your code for you, but will happily help if there is something that needs explaining or clarification.
Rashmil Dahanayake

on 23 Sep 2014

### Stephen Cobeldick (view profile)

on 19 Sep 2014

Try setxor :
setxor(A,1:80)

Stephen Cobeldick

### Stephen Cobeldick (view profile)

on 19 Sep 2014
Rashmil Dahanayake

### Rashmil Dahanayake (view profile)

on 20 Sep 2014
see my updated answer incorporating Fabios

### Fabio Freschi (view profile)

on 19 Sep 2014

Try this
A=[1 2 3 6 7 45 46 47 53 78 80];
all = 1:80;
missing = setdiff(all,A);
Fabio

#### 1 Comment

Rashmil Dahanayake

### Rashmil Dahanayake (view profile)

on 19 Sep 2014
this method also works

### Rashmil Dahanayake (view profile)

on 19 Sep 2014
Edited by Rashmil Dahanayake

### Rashmil Dahanayake (view profile)

on 19 Sep 2014

Full Answer for my question asked previously. In case if someone might find it usefull
A=1:3:20; % in complete data
B=1:20; % Full index
missing = setdiff(B,A); % check for missing elements