Revision 495
(checked in by cbc, 12 years ago)
|
Initial import of Stark code.
|
Line | |
---|
1 |
|
---|
2 |
function [data]=read_lbe(fname); |
---|
3 |
|
---|
4 |
% Last modified: 23 Sept 1999 |
---|
5 |
% Catherine R. Edwards |
---|
6 |
|
---|
7 |
if nargin==0 & nargout==0 |
---|
8 |
disp('Call as: [data]=read_lbe(fname);') |
---|
9 |
return |
---|
10 |
end |
---|
11 |
|
---|
12 |
if ~exist('fname') |
---|
13 |
[fname,fpath]=uigetfile('*.lbe','Which .lbe ?'); |
---|
14 |
if fname==0,return,end |
---|
15 |
else |
---|
16 |
fpath=[]; |
---|
17 |
end |
---|
18 |
|
---|
19 |
% get filetype from tail of fname |
---|
20 |
ftype=fname(length(fname)-2:length(fname)); |
---|
21 |
|
---|
22 |
% make sure this is an allowed filetype |
---|
23 |
if ~strcmp(ftype,'lbe') |
---|
24 |
error(['READ_LBE cannot read ' ftype ' filetype']) |
---|
25 |
end |
---|
26 |
|
---|
27 |
% open fname |
---|
28 |
[pfid,message]=fopen([fpath fname]); |
---|
29 |
if pfid==-1 |
---|
30 |
error([fpath fname,' not found. ',message]); |
---|
31 |
end |
---|
32 |
|
---|
33 |
% In all filetypes there is always a gridname and description line |
---|
34 |
% as lines #1 and #2 of the file. |
---|
35 |
% read grid name from top of file; header line #1 |
---|
36 |
% gridname=fgets(pfid); |
---|
37 |
% gridname=blank(gridname); |
---|
38 |
|
---|
39 |
% read data segment |
---|
40 |
data=fscanf(pfid,'%d %f %f',[3 inf])'; |
---|
41 |
fclose(pfid); |
---|