Matlab在石油工程中应用|把MATLAB计算的曲线曲面导入ANSYS

function mat2ans(filename,x,y,z) %把MATLAB计算的曲线曲面导入ANSYS t=0:pi/10:2*pi; [x,y,z]=cylinder(2+cos(t)); filename=strcat('c1.txt'); if(ischar(filename)==0) error('Invalid filename'); end if(ndims(z)~=2) error('Variable z must be a 2-dimensional array'); end if any((size(x)~=size(z))|(size(y)~=size(z)))% size of x or y does not size of z if((length(x)==1)&(length(y)==1)) % Must be specifying dx and dy, so make vectors dx=x; dy=y; x=((1:size(z,2))-1)*dx; y=((1:size(z,1))-1)*dy; end if((length(x)==size(z,2))&(length(y)==size(z,1))) % Must be specifying vectors xvec=x; yvec=y; [x,y]=meshgrid(xvec,yvec); else error('Unable to resolve x and y variables'); end end fid=fopen(filename,'w'); if(fid==-1) error(sprintf('Unable to write to %s',filename)); end [m,n]=size(z); x=reshape(x',m*n,1); y=reshape(y',m*n,1); z=reshape(z',m*n,1); % 进入前处理 fprintf(fid,'/prep7\r\n'); % 创建关键点 for i=1:m*n fprintf(fid,'k,%4.d,%.5f,%.5f,%.5f,\r\n',i,x(i),y(i),z(i)); end % 创建样条线 for i=1:m fprintf(fid,'FLST,3,%3.d,3\r\n',n); for j=1:n fprintf(fid,'FITEM,3,%4.d,\r\n',j+(i-1)*n); end fprintf(fid,'BSPLIN, ,P51X\r\n'); end % 由蒙皮技术创建面 fprintf(fid,'FLST,2,%2.d,4\r\n',m); for i=1:m fprintf(fid,'FITEM,2,%d\r\n',i); end fprintf(fid,'ASKIN,P51X\r\n'); fprintf(fid,'ldele,all\r\n'); fprintf(fid,'kdele,all\r\n'); fprintf(fid,'aplot\r\n'); fprintf(fid,'NUMCMP,ALL\r\n'); fprintf(fid,'FINISH\r\n'); fclose(fid);

【Matlab在石油工程中应用|把MATLAB计算的曲线曲面导入ANSYS】作者:LiW

    推荐阅读