انتقال داده هاي بيانگر نمودارهاي دوبعدي از متلب به اتوكد
اين يك نسخه اوليه بسيار قديمي هست كه حدود 10 سال پيش نوشته ام. چگونگي استفاده از آن هم، با توجه به شكلها مشخص و گوياست. نمونه را هم عمداً اينگونه ساخته ام تا كارآيي تابع Mat2CAD در هنگام برخورد با Inf و NaN نمايان شود.
اين يك نسخه اوليه بسيار قديمي هست كه حدود 10 سال پيش نوشته ام. چگونگي استفاده از آن هم، با توجه به شكلها مشخص و گوياست. نمونه را هم عمداً اينگونه ساخته ام تا كارآيي تابع Mat2CAD در هنگام برخورد با Inf و NaN نمايان شود.
function Mat2CAD(x,y,fname,color,zoomopt)
%MAT2CAD Converting of MATLAB 2D-graph data to AutoCAD script file.
% MAT2CAD(X,Y,FNAME) creates an AutoCAD script file from data vectors
% X and Y. X and Y must be vector arrays with the same length. They may
% contain Inf and/or NaN.
% FNAME is the Output Script File Name, with extension scr.
% This function is using just AutoCAD pline command for plotting.
%
% Numerical Recipes for Solving Engineering Problems using MATLAB
% By: Mehdi Mosafer, Rev. 0.1, 2001.
% http://mmnrecipes.blogspot.com
L=length(x);
j1=find(isinf(y));
j2=find(isnan(y));
j=[j1(:);j2(:)];
fid=fopen([fname,'.scr'],'wt');
if (nargin>3)&&(~isempty(color))
fprintf(fid,'cecolor\n');
fprintf(fid,[num2str(color),'\n']);
end
fprintf(fid,'pline\n');
for k=1:L
if ~isempty(find(k==j))
fprintf(fid,'\n');
fprintf(fid,'pline\n');
else
fprintf(fid,'%g',x(k));
fprintf(fid,',');
fprintf(fid,'%g\n',y(k));
end
end
fprintf(fid,'\n');
if (nargin<5)||((nargin>4)&&(zoomopt==1))
fprintf(fid,'zoom\n');
fprintf(fid,'extents\n');
fprintf(fid,'\n');
end
fclose(fid);
%MAT2CAD Converting of MATLAB 2D-graph data to AutoCAD script file.
% MAT2CAD(X,Y,FNAME) creates an AutoCAD script file from data vectors
% X and Y. X and Y must be vector arrays with the same length. They may
% contain Inf and/or NaN.
% FNAME is the Output Script File Name, with extension scr.
% This function is using just AutoCAD pline command for plotting.
%
% Numerical Recipes for Solving Engineering Problems using MATLAB
% By: Mehdi Mosafer, Rev. 0.1, 2001.
% http://mmnrecipes.blogspot.com
L=length(x);
j1=find(isinf(y));
j2=find(isnan(y));
j=[j1(:);j2(:)];
fid=fopen([fname,'.scr'],'wt');
if (nargin>3)&&(~isempty(color))
fprintf(fid,'cecolor\n');
fprintf(fid,[num2str(color),'\n']);
end
fprintf(fid,'pline\n');
for k=1:L
if ~isempty(find(k==j))
fprintf(fid,'\n');
fprintf(fid,'pline\n');
else
fprintf(fid,'%g',x(k));
fprintf(fid,',');
fprintf(fid,'%g\n',y(k));
end
end
fprintf(fid,'\n');
if (nargin<5)||((nargin>4)&&(zoomopt==1))
fprintf(fid,'zoom\n');
fprintf(fid,'extents\n');
fprintf(fid,'\n');
end
fclose(fid);