How to replace/remove duplicate columns datas in a .dat file?
显示 更早的评论
Hello all,
I have a question about how to replace/remove duplicate columns datas in .dat file?
There is a duplicate data of .dat file:
A B C D
0.3 0.8 2.1 6.7
0.3 0.8 2.2 6.6
0.3 0.8 2.5 6.4
0.3 0.6 2.7 6.2
0.3 0.6 2.8 6.0
0.3 0.6 3.0 5.9
...
...
How should I do if the expected output should simply be:
A = 0.3; B = 0.8:
C D
2.1 6.7
2.2 6.6
2.5 6.4
...
...
---------------------
A = 0.3; B = 0.6:
C D
2.7 6.2
2.8 6.0
3.0 5.9
...
...
I tried to use unique to solve, but it deleted my entire row. And what kinds function should I use for edit .dat files? fopen?fscanf?fwrite?
Thanks for all the patience and helps :)
Best regards.
回答(1 个)
Walter Roberson
2022-4-11
0 个投票
findgroups() to find the A, B combinations.
Possibly use splitapply() to process the groups.
类别
在 帮助中心 和 File Exchange 中查找有关 Get Started with MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!