MATLAB: Importing periodic data with textscan and fgetl

fgetlimportperiodic datatextscan

Here's a subset of the data I'm trying to import into MATLAB:
Time = 0.50734E-01
X Y Z EP_g
23.865 25.227 -0.50000 0.56828
24.135 25.227 -0.50000 0.56839
23.865 25.500 -0.50000 0.56834
24.135 25.500 -0.50000 0.56831
Time = 1.00059E-01
X Y Z EP_g
23.865 25.227 -0.50000 0.56828
24.135 25.227 -0.50000 0.56840
23.865 25.500 -0.50000 0.56835
24.135 25.500 -0.50000 0.56832
I am trying to import this data using textscan and fgetl but have been having trouble. The problem is those pesky lines between each subset.
The column on the far right (EP_g) is the only thing I'm really interested in. By the time I'm done, I just want a matrix with the transpose of the EP_g column along the rows, i.e.,
data =
0.56828 0.56839 0.56834 0.56831
0.56828 0.56840 0.56835 0.56832
My attempt at a solution:
fid=fopen(file)
while ~feof(fid)
tmp=textscan(fid,'%f%f%f%f','Headerlines',5)
for j=[1:2]
fgetl(fid)
end;
end;
fclose(fid);
I would appreciate any guidance or help you can give me. Many thanks!

Best Answer

I managed to get it to work by using only the textscan function. I had seen an example using fgetl and I thought I needed it for this application, but it turns out I didn't.
fid=fopen('n90deg'); % Open file
c=1; % Initialize counter
while ~feof(fid); % Run until end of file
tmp=textscan(fid,'%f%f%f%f','Headerlines',2); % Omit first two lines every
% time
n90deg(c,:)=tmp{4}'; % Store the last cell as a row in new matrix
c=c+1; % Add to counter and repeat above steps
end
fclose(fid);
Hopefully someone else will find this useful.