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
把MATLAB计算的曲线曲面导入ANSYS
最新推荐文章于 2023-02-06 17:43:29 发布