Matlab将一组单元导入到Tecplot中查看
function ToTecplot3D(p,t,Usum,filename) % --------- p should be 3*N or N*3 ---------------------------- % --------- T should be 4*N or N*4 or 8*N or N*8---------------------------- % --------- U should be 1*N or 1*N or 0 ----------------------- % --------- filename should be as 'xxx.txt' or 'xxx' ---------- if size(p,1)==3 flag_p=1; elseif size(p,2)==3 p = p'; else msgbox('坐标p应该是3×N,未输出文件','错误') return end if size(t,1)==8 || size(t,1)==4 flag_t = 1; elseif size(t,2)==8 || size(t,2)==4 t = t'; else msgbox('单元t应该是4×N 或 8×N,未输出文件','错误') return end if Usum ==0 Usum = ones(1,size(p,2)); elseif size(Usum,1)==1 flag_t = 1; elseif size(Usum,2)==1 Usum = Usum'; else msgbox('位移U应该是1×N,未输出文件','错误') return end if ~ismember('.',filename) filename = [filename,'.txt']; end fid=fopen(filename,'w'); fprintf(fid,'TITLE = "Example: Xdd1997 Data"\n'); fprintf(fid,'VARIABLES = "X", "Y","Z","Displacement"\n '); % lineseg, tringle, quadrilateral tetrahedron, or brick if size(t,1) == 4 fprintf(fid,'ZONE N = %d E = %d ET = tetrahedron F=FEPOINT\n',size(p,2),size(t,2)); else fprintf(fid,'ZONE N = %d E = %d ET = Brick F=FEPOINT\n',size(p,2),size(t,2)); end CD_results=[p;Usum]; fprintf(fid,'%16.9f %16.9f %16.9f %16.9f\n',CD_results); if size(t,1) == 4 fprintf(fid,'%d %d %d %d\n',t); else fprintf(fid,'%d %d %d %d %d %d %d %d\n',t); end fclose(fid); disp([filename,' 文件输出成功'])
本文来自博客园,作者:xdd1997
转载请注明:https://www.cnblogs.com/xdd1997/p/14837380.html
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步