Dear all, i'm dealing with a problem: I have a .txt table and i want to write and delete the last n rows of this table using a condition or statement (here named solution).
here is the .txt table (shorelines.txt):
Station Profile_number shoreline_number east north distance_along_swath shoreline_elevation error analysis_type timeCLMO 5 1 681775 5955821 101.18 11.67 0.98 classic 735513.08088CLMO 7 1 681295 5955779 197.57 50.48 4.15 classic 735513.08133CLMO 7 2 681350 5955683 86.25 19.54 0.96 classic 735513.08154CLMO 9 1 681116 5955539 98.12 21.44 0.67 classic 735513.08208CLMO 9 2 681114 5955540 100.87 24.03 1.21 classic 735513.08231CLMO 10 1 681073 5955484 82.87 19.94 0.62 stack 735513.08275
First I readed the table in this way:
clear%load shorelines table
file=('shorelines.txt');fid=fopen(file,'r');i=1;while ~feof(fid) %tline = fgetl(fid);
A=textscan(fid,'%s %u %u %f %f %f %f %f %s %f\r\n','delimiter',' ','HeaderLines',1); for j=1:10 %number of columns (default)
data(i,j) = A(1,j); end i=i+1; endclear j i
then I create the conditions defined as:
solution==1 %delete the last three rows of the table
solution==2 %delete the two last rows of the table
solution==3 %delete just the last row of the table
i've been trying to develop a method to delete the rows but none works. For instance, i try this:
if solution==3tline(nim)=fgetl(nim) ;fclose(fid); end
but nothing happens… somebody have an idea how to deal with .txt tables? thanks a lot in advance…
Best Answer