MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

# How to find remaining row values from text file..?

Asked by Lalit Patil on 31 Dec 2012

I have this data1.txt file.

``` 37.423588 18.871724 11.705919
37.426766 18.766546 11.701217
38.005723 18.134451 11.634655
39.041007 17.277316 11.527277
40.011146 15.164824 11.370832
40.007967 15.088475 11.367794
36.502911 20.190672 14.325146
35.914974 20.920768 16.896500
35.975486 20.946253 16.893447
36.062043 21.046045 16.891779
41.012003 13.878586 16.247513
40.987450 13.766184 16.244401
34.466285 23.481801 27.104811```

And this is the data2.txt file.

``` 37.283855 18.272258 11.689920
37.457463 18.622919 11.692993
38.008732 17.937276 11.626042
37.986514 17.777689 11.620758
39.772352 14.385744 11.353952
36.628875 20.010218 14.308833
36.634567 19.895388 14.303548
37.604998 20.055999 14.244000
41.275247 16.978169 13.861658
40.485970 15.036456 13.832871```

Here in data1.txt file it contains first column with values 34,35,36,37,38,39,40 and 41.

No, data2.txt contains only 36,37,38,39,40 and 41 values in first column.

Now, i have to find remaining values rows like 34 and 35. so how to do it..?

Walter Roberson on 31 Dec 2012

Are you looking for exact matches, or are you wanting to round() the values or are you wanting to floor() them ?

Lalit Patil on 31 Dec 2012

Not, exact matches.? Only comparision of decimals before point. But answer should be whole row with points after decimal.

``` 35.914974 20.920768 16.896500
35.975486 20.946253 16.893447
34.466285 23.481801 27.104811```

## Products

No products are associated with this question.

Answer by Image Analyst on 31 Dec 2012

You can use ismember():

```data1=[...
37.423588 18.871724 11.705919
37.426766 18.766546 11.701217
38.005723 18.134451 11.634655
39.041007 17.277316 11.527277
40.011146 15.164824 11.370832
40.007967 15.088475 11.367794
36.502911 20.190672 14.325146
35.914974 20.920768 16.896500
35.975486 20.946253 16.893447
36.062043 21.046045 16.891779
41.012003 13.878586 16.247513
40.987450 13.766184 16.244401
34.466285 23.481801 27.104811]
```
```data2=[...
37.283855 18.272258 11.689920
37.457463 18.622919 11.692993
38.008732 17.937276 11.626042
37.986514 17.777689 11.620758
39.772352 14.385744 11.353952
36.628875 20.010218 14.308833
36.634567 19.895388 14.303548
37.604998 20.055999 14.244000
41.275247 16.978169 13.861658
40.485970 15.036456 13.832871]
```
```col1data1 = unique(floor(data1(:,1)))
col1data2 = unique(floor(data2(:,1)))
```
```contained = ismember(col1data1, col1data2)
intersect(col1data1, col1data2)  % Just FYI
union(col1data1, col1data2) % Just FYI
```
```notInData2 = col1data1(~contained)
```

Walter Roberson on 31 Dec 2012
```col1data1 = floor(data1(:,1));
col1data2 = floor(data2(:,1));
contained = ismember(col1data1, col1data2);
notIndata2 = data(~contained, :);
```
Lalit Patil on 31 Dec 2012

It works.. Thank you .. How to accept this answer.?

Walter Roberson on 31 Dec 2012

There should be an "Accept This Answer" near Image Analyst's name on the Answer part itself.