clear all close all t3sFilename = 'Daly_5m_Mesh.t3s'; BathyIndex = 1; fid = fopen(t3sFilename,'r'); tline = fgets(fid); while strcmp(tline(1:min(length(tline),10)),':EndHeader')== 0 if strcmp(tline(1:min(length(tline),10)),':NodeCount')== 1 nodeCount=str2num(tline(11:end)); end if strcmp(tline(1:min(length(tline),13)),':ElementCount')== 1 elementCount=str2num(tline(14:end)); end tline = fgets(fid); end tline = fgets(fid); %%%%Read T3S File for i = 1 : nodeCount tempLine=strsplit(tline,' '); node(i).X = str2num(tempLine{1}); node(i).Y = str2num(tempLine{2}); node(i).Z = str2num(tempLine{2+BathyIndex}); tline = fgets(fid); end for i = 1 : elementCount tempLine=strsplit(tline,' '); element(i).p1 = str2num(tempLine{1}); element(i).p2 = str2num(tempLine{2}); element(i).p3 = str2num(tempLine{3}); tline = fgets(fid); end fclose(fid) rmaFilename = [t3sFilename(1:end-3) , 'rm1']; fid1 = fopen(rmaFilename,'w'); fprintf(fid1,'\n'); fprintf(fid1,' 0 1 1 1 1 1 0 0 0 0 1 0 0 1 0 0.0 0.0 2\n'); fprintf(fid1,' 0. 0. 0.0000 0.0000 0.0000 0.0000 0. 0.\n'); for i = 1 : elementCount fprintf(fid1,'%5.0f%5.0f 0%5.0f 0%5.0f 0 0 0 1 0.000%5.0f\n', ... i,element(i).p1,element(i).p2,element(i).p3,i); end fprintf(fid1,' 9999\n'); for i = 1 : nodeCount fprintf(fid1,'%10.0f%16.7f%20.7f%14.4f%70.0f 0.0000\n', ... i,node(i).X,node(i).Y,node(i).Z,0); end fprintf(fid1,' 9999\n'); fprintf(fid1,' 9999\n'); fprintf(fid1,' 0 NENTRY\n'); fprintf(fid1,' 0 NCLM\n'); fprintf(fid1,'ENDDATA\n');