Changeset 2607
- Timestamp:
- 11/05/09 08:46:47 (15 years ago)
- Location:
- issm/trunk/src/m/utils/Exp
- Files:
-
- 3 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/m/utils/Exp/expdoc.m
r1 r2607 33 33 disp(' expselect: display all the profiles of oldfile, the user clicks on the contour he/she wants to remove. Results saved in newfile'); 34 34 disp(' usage: expselect(newfile,oldfile)'); 35 disp(' expwriteasvertices: writes an Argus file from a structure given in input???');36 disp(' usage: expwriteasvertices(structure,filename)');37 35 disp(' expwrite: writes an Argus file from a structure given in input???'); 38 36 disp(' usage: expwrite(structure,filename)'); -
issm/trunk/src/m/utils/Exp/readwrite/expread.m
r1260 r2607 1 function struct=expread(name,whole);2 %EXPREAD - read a file exp and build a structure1 function Struct=expread(filename,whole); 2 %EXPREAD - read a file exp and build a Structure 3 3 % 4 % This routine reads a file .exp and build a structure containing the5 % fields x and y corresponding to the coordinates, one for the name of4 % This routine reads a file .exp and build a Structure containing the 5 % fields x and y corresponding to the coordinates, one for the filename of 6 6 % the exp file, for the density, for the nodes, and a field closed to 7 7 % indicate if the domain is closed. … … 10 10 % 11 11 % Usage: 12 % struct=expread(name,whole)12 % Struct=expread(filename,whole) 13 13 % 14 14 % Example: 15 % struct=expread('domainoutline.exp',1)15 % Struct=expread('domainoutline.exp',1) 16 16 % 17 17 % See also EXPDOC, EXPWRITEASVERTICES 18 18 19 19 %some checks 20 if ~exist(name), 21 error(['expread error message: file ' name ' not found!']); 20 if ~exist(filename), 21 error(['expread error message: file ' filename ' not found!']); 22 end 23 if nargin~=2, 24 help expread 25 error('expread error message: second argument not provided'), 22 26 end 23 27 24 try, 25 fid=fopen(name,'r'); 26 i=0; 28 %initialize number of profile 29 count=0; 30 31 %open file 32 fid=fopen(filename,'r'); 33 34 %loop over the number of profiles 27 35 while (~feof(fid)), 28 i=i+1; 29 %firt line contains the name 30 A=readline(fid,2); 31 if length(A)>8, 32 struct(i).name=A(9:length(A)); 36 37 %update number of profiles 38 count=count+1; 39 40 %Get file name 41 A=fscanf(fid,'%s %s',2); 42 if ~strncmp(A,'##Name:',7), break; end 43 if length(A)>7, 44 Struct(count).name=A(8:end); 45 else 46 Struct(count).name=''; 47 end 48 49 %Get Icon 50 A=fscanf(fid,'%s %s',2); 51 if ~strncmp(A,'##Icon:',6), break; end 52 53 %Get Info 54 A=fscanf(fid,'%s %s %s %s',4); 55 if ~strncmp(A,'#Points',7), break; end 56 57 %Get number of nods and density 58 A=fscanf(fid,'%f %f',[1 2]); 59 if whole==1, 60 Struct(count).nods=A(1); 61 else 62 Struct(count).nods=A(1)-1; 33 63 end 64 Struct(count).density=A(2); 34 65 35 A=readline(fid,2); 36 A=readline(fid,4); 66 %Get Info 67 A=fscanf(fid,'%s %s %s %s',5); 68 if ~strncmp(A,'#XposYpos',9), break; end 37 69 38 [A,bytecount]=fscanf(fid,'%f %f',[1 2]); 39 if whole==1, 40 struct(i).nods=A(1); 41 else 42 struct(i).nods=A(1)-1; 43 end 44 struct(i).density=A(2); 45 A=readline(fid,5); 70 %Get Coordinates 71 A=fscanf(fid,'%f %f',[2 Struct(count).nods]); 72 Struct(count).x=A(1,:)'; 73 Struct(count).y=A(2,:)'; 46 74 47 struct(i).x=zeros(struct(i).nods,1); 48 struct(i).y=zeros(struct(i).nods,1); 49 struct(i).closed=0; 50 51 for n=1:struct(i).nods, 52 [A,bytecount]=fscanf(fid,'%f %f',[1 2]); 53 struct(i).x(n)=A(1); 54 struct(i).y(n)=A(2); 55 end 56 if whole==0, 57 fscanf(fid,'%f %f',[1 2]); 58 end 75 %skip last coordinate if whole=0, 76 if whole==0, fscanf(fid,'%f %f',[1 2]); end 59 77 60 78 end 61 catch, 62 end 79 80 %close file 63 81 fclose(fid);
Note:
See TracChangeset
for help on using the changeset viewer.