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

1 view (last 30 days)
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..?
  2 Comments
Walter Roberson
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
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.
In this answer should be
35.914974 20.920768 16.896500
35.975486 20.946253 16.893447
34.466285 23.481801 27.104811

Sign in to comment.

Accepted Answer

Image Analyst
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)
  11 Comments
Lalit Patil
Lalit Patil on 31 Dec 2012
It works.. Thank you .. How to accept this answer.?
Walter Roberson
Walter Roberson on 31 Dec 2012
There should be an "Accept This Answer" near Image Analyst's name on the Answer part itself.

Sign in to comment.

More Answers (0)

Categories

Find more on Reporting and Database Access in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!