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

1 回表示 (過去 30 日間)
Lalit Patil
Lalit Patil 2012 年 12 月 31 日
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 Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by