expread

PURPOSE ^

EXPREAD - read a file exp and build a structure

SYNOPSIS ^

function struct=expread(name,whole);

DESCRIPTION ^

EXPREAD - read a file exp and build a structure

   This routine reads a file .exp and build a structure containing the 
   fields x and y corresponding to the coordinates, one for the name of
   the exp file, for the density, for the nodes, and a field closed to 
   indicate if the domain is closed. 
   The first argument is the .exp file to be read and the second one 
   indicate if the last point shall be read (1 to read it, 0 not to).

   Usage:
      struct=expread(name,whole)
  
   Example:
      struct=expread('domainoutline.exp',1)

   See also EXPDOC, EXPWRITEASVERTICES

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function struct=expread(name,whole);
0002 %EXPREAD - read a file exp and build a structure
0003 %
0004 %   This routine reads a file .exp and build a structure containing the
0005 %   fields x and y corresponding to the coordinates, one for the name of
0006 %   the exp file, for the density, for the nodes, and a field closed to
0007 %   indicate if the domain is closed.
0008 %   The first argument is the .exp file to be read and the second one
0009 %   indicate if the last point shall be read (1 to read it, 0 not to).
0010 %
0011 %   Usage:
0012 %      struct=expread(name,whole)
0013 %
0014 %   Example:
0015 %      struct=expread('domainoutline.exp',1)
0016 %
0017 %   See also EXPDOC, EXPWRITEASVERTICES
0018 
0019 try,
0020 fid=fopen(name,'r');
0021 i=0;
0022 while (~feof(fid)),
0023    i=i+1;
0024    %firt line contains the name
0025    A=readline(fid,2);
0026    if length(A)>8, 
0027        struct(i).name=A(9:length(A));
0028    end
0029 
0030    A=readline(fid,2);
0031    A=readline(fid,4);
0032 
0033    [A,bytecount]=fscanf(fid,'%f %f',[1 2]);
0034    if whole==1,
0035        struct(i).nods=A(1);
0036    else
0037        struct(i).nods=A(1)-1;
0038    end
0039    struct(i).density=A(2);
0040    A=readline(fid,5);
0041 
0042    struct(i).x=zeros(struct(i).nods,1);
0043    struct(i).y=zeros(struct(i).nods,1);
0044    struct(i).closed=0;
0045 
0046    for n=1:struct(i).nods,
0047        [A,bytecount]=fscanf(fid,'%f %f',[1 2]);
0048        struct(i).x(n)=A(1);
0049        struct(i).y(n)=A(2);
0050    end
0051    if whole==0,
0052        fscanf(fid,'%f %f',[1 2]);
0053    end
0054 
0055 end
0056 catch,
0057 end
0058 fclose(fid);

Generated on Sun 29-Mar-2009 20:22:55 by m2html © 2003