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

Answers (2)

Ameer Hamza
Ameer Hamza on 13 Nov 2020
Edited: Ameer Hamza on 13 Nov 2020
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,:)

Categories

Find more on MATLAB in Help Center and File Exchange

Products

Release

R2011a

Tags

Asked:

on 13 Nov 2020

Edited:

on 13 Nov 2020

Community Treasure Hunt

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

Start Hunting!