Delete the duplicate rows

Hi,
trying in matlab
Simple the had the data repeating it for 32sec.
I need to to write into other file by taking only one sample.
0.007500 34.220001 1995.584000
0.007500 34.220001 1995.584000
0.007500 34.220001 1995.584000
0.007500 34.220001 1995.584000
0.007500 34.220001 1995.584000
0.007500 34.220001 1995.584000
0.007500 34.220001 1995.584000
0.007500 34.220001 1995.584000
0.007500 34.220001 1995.584000
0.007500 34.220001 1995.584000
0.007500 34.220001 1995.584000
0.007500 34.220001 1995.584000
0.007500 34.220001 1995.584000
0.007500 34.220001 1995.584000
0.007500 34.220001 1995.584000
0.007500 34.220001 1995.584000
0.007500 34.220001 1995.584000
0.007500 34.220001 1995.584000
0.007500 34.220001 1995.584000
0.007500 34.220001 1995.584000
0.007500 34.220001 1995.584000
0.007500 34.220001 1995.584000
0.007500 34.220001 1995.584000
0.007500 34.220001 1995.584000
0.007500 34.220001 1995.584000
0.007500 34.220001 1995.584000
0.007500 34.220001 1995.584000
0.007500 34.220001 1995.584000
0.007500 34.220001 1995.584000
0.007500 34.220001 1995.584000
0.007500 34.220001 1995.584000
0.007500 34.220001 1995.584000
0.085000 111.720001 75.584000
0.085000 111.720001 75.584000
0.085000 111.720001 75.584000
Tried this code
clc;
clear all;
close all;
fp10 = fopen('inu03.rdt', 'r');
fpid10 = fopen('inuo3_final.out','w');
i=0;
while ~feof(fp10)
i=i+1;
scan1 = fscanf(fp10,'%f %f %f ',[3,1]);
x2 = scan1(1);
fprintf('%d\n',i);
temp =x2;
c = temp-x2;
if(c>=0.08)
fprintf(fpid10,' %10.6f \n',x2);
end
end

回答(2 个)

Ameer Hamza
Ameer Hamza 2020-11-13
编辑:Ameer Hamza 2020-11-13
You can use unique() function
data = load('data.txt');
data_unique = unique(data, 'rows');
data.txt is attached.
Or if data is repeating after constant interval of 32 the following will be faster
data = load('data.txt');
data_unique = data(1:32:end,:)

类别

在 帮助中心 和 File Exchange 中查找有关 MATLAB 的更多信息

产品

版本

R2011a

标签

提问:

2020-11-13

编辑:

2020-11-13

Community Treasure Hunt

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

Start Hunting!

Translated by