I have a file named Myfile.txt with a header and three rows of data:
Header Row1 Row2 Row3
5.10 10 15
5.20 20 25
5.30 30 35
5.40 40 45
5.50 50 55
5.60 60 65
5.70 70 75
5.80 80 85
5.90 90 95
5.95 10 20
6.00 25 30
6.05 35 40
I want to read in every 3 lines that increment the first column by .1 and then all lines after the increment to .05, so my output looks like:
5.30 30 35
5.60 60 65
5.90 90 95
5.95 10 20
6.00 25 30
6.05 35 40
I have the following code but I don't know how to implement the condition, can I get some help doing this?
per_line = 3;
every_nth_line = 3;
fmt = [repmat('%*f',1,per_line*(every_nth_line-1)), repmat('%f',1,per_line)];
fid = fopen('Myfile.txt','rt');
datacell = textscan(fid,fmt,'delimiter','\n','HeaderLines',1,'CollectOutput',1);
fclose(fid);
C=datacell{1};
Aucun commentaire:
Enregistrer un commentaire