function ExpRead1

% Since it's not quite easy to plot the Thermo-Calc simulation results,
% this script is dedicated for the easy handle of TC results using matlab.
% The basic idea contains reading the EXP file, and then plot them. As I,
% myself is not a expert in TC, hence my understanding of EXP file is far
% from complete. I will keed updating it to include new file format I'll
% meet. Feel free to contact me by renqingqiang@gmail.com. 

% If your exp file only contains one set of lines, or you don't care about
% the difference between different sets of lines, this is the right one for
% you. If not, try ExpRead2.m before you write your own script.

[file,path] = uigetfile('*.exp','EXP file generated by Thermo-Calc');

f=strcat(path,file);

fid = fopen(f,'r');
num = 1;
fid2 = fopen(strcat(file,'.dat'),'w');
while(~feof(fid))
tline = fgetl(fid);
num = num+1;
if (length(tline) >= 9 && strcmp(tline(1:9),'$ PLOTTED'))
    tline = fgetl(fid);
    num = num+1;
    while (tline(1) ~= 'B')
        fprintf(fid2,'%s \n',tline);
%         disp(tline);
        tline = fgetl(fid);
        num = num+1;
    end
    fprintf(fid2,'%s \n', '  ');
else
    continue;
end

end
fclose('all');

