Removing lines/rows containing 0.00... in the final column of a .txt file - MATLAB

1 view (last 30 days)
Hi,
I'm currently writing large data-sets to .txt files proceeding smoothing values with MATLAB using the commands:
hann500=hanning(500);
yy=conv(y,hann500,'same');
fileID = fopen('chrI500bp.txt','w');
for i = 1:length(x)
fprintf(fileID,'%s\t%d\t%d\t%f\n', 'chrI', x(i),x(i),yy(i));
end
fclose(fileID);
Is there a way I can get MATLAB to process the .txt file after creating it to remove all lines containing null-values (0.000....) in the final column (such as those shown below)?
chrI 1983 1983 0.000000
chrI 1984 1984 0.000000
chrI 1985 1985 0.000000
chrI 1986 1986 0.000000
chrI 1987 1987 0.000000
chrI 1988 1988 0.000000
chrI 1989 1989 0.000000
chrI 1990 1990 0.000000
chrI 1991 1991 0.000000
chrI 1992 1992 0.000039
chrI 1993 1993 0.000157
chrI 1994 1994 0.000354
chrI 1995 1995 0.000629
chrI 1996 1996 0.000983
chrI 1997 1997 0.001415
chrI 1998 1998 0.001925
chrI 1999 1999 0.002514
Thanks!
- TJC

Answers (1)

Azzi Abdelmalek
Azzi Abdelmalek on 24 Dec 2013
Edited: Azzi Abdelmalek on 24 Dec 2013
A={ 'chrI' 1983 1983 0.000000
'chrI' 1984 1984 0.000000
'chrI' 1985 1985 0.000000
'chrI' 1992 1992 0.000039
'chrI' 1993 1993 0.000157}
out=A(~~cell2mat(A(:,4)),:)

Community Treasure Hunt

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

Start Hunting!