-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathread_HOC.m
More file actions
39 lines (28 loc) · 1.06 KB
/
read_HOC.m
File metadata and controls
39 lines (28 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
function [A, unitstr] = read_HOC(fname)
% [A, unitstr] = read_HOC(fname)
%
% fname = name of ascii file
%HOCDIR = 'C:\Tamar\Matlab\glass data toolbox\Handbook of Optical Constants\ascii tables\';
%HOCDIR = 'C:\Users\dmarx\OneDrive\Matlab\glass data toolbox\Handbook of Optical Constants\ascii tables\';
pn = regexp(userpath,'\','split');
HOCDIR = fullfile(pn{:}, '\glass data toolbox\Handbook of Optical Constants\ascii tables\');
fid = fopen(fullfile(HOCDIR, fname),'rt');
if fid == -1, error(['cannot open file: ' HOCDIR fname]); end
lcnt = 1;
tline = fgetl(fid);
while ~strncmp(strtrim(tline),'eV',2),
tline = fgetl(fid);
lcnt = lcnt + 1;
end
unitstr = textscan(tline,'%s');
unitstr = unitstr{1}; % cell of cells
% Nunits = length(unitstr);
% next line is '-----------'
tline = fgetl(fid);
lcnt = lcnt + 2;
A = textscan(fid,'%f %f %f %f %f %f','delimiter',':', 'EmptyValue', -Inf);
fclose(fid);
%A = reshape(A{1},Nunits,length(A{1})/Nunits).';
% %A = textread([HOCDIR fname],'','headerlines',lcnt,'delimiter',':');
% A = dlmread([HOCDIR fname],':',lcnt,1);
end