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

1 次查看(过去 30 天)
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 个评论
Walter Roberson
Walter Roberson 2012-12-31
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 2012-12-31
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

请先登录,再进行评论。

采纳的回答

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

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by