MATLAB: How to read a textfile without header and commas

fscanfopentext filetextscan

Hi everybody. I'm trying to analyze some data in .txt format and the file is like this:
"Record Length",50002,"Points",-2e-005,0
"Sample Interval",4e-009,s,-1.9996e-005,0
"Trigger Point",5000,"Samples",-1.9992e-005,0
"Trigger Time",0.00774621,s,-1.9988e-005,-2.20973
,,,-1.9984e-005,-4.41946
"Horizontal Offset",-2e-005,s,-1.998e-005,0
,,,-1.9976e-005,0
,,,-1.9972e-005,0
,,,-1.9968e-005,-2.20973
,,,-1.9964e-005,0
,,,-1.996e-005,0
,,,-1.9956e-005,-2.20973
,,,-1.9952e-005,0
,,,-1.9948e-005,-2.20973
,,,-1.9944e-005,2.20973
,,,-1.994e-005,-2.20973
,,,-1.9936e-005,0
,,,-1.9932e-005,2.20973
,,,-1.9928e-005,0
It has something like 50000 rows. For open it I used this code:
fname=('C1HVLVlipo00003.txt');
if exist(fname,'file')
fid = fopen(fname);
fgets(fid);
fgets(fid);
fgets(fid);
fgets(fid);
fgets(fid);
fgets(fid);
fgets(fid);
fgets(fid);
rawdata = fscanf(fid, ',,,%f%,''%f\n');
end
But it put in rawdata al the number in a column, and not in two like I want. Because I want to separate the numbers before, and after the comma, without the header and without the three commas. Thank you.

Best Answer

rawdata = fscanf(fid, ',,,%f,%f', [2 inf]) .';
Related Question