Matlab產(chǎn)生IGES文件代碼【matlab源碼】

上傳人:飛****9 文檔編號(hào):61855511 上傳時(shí)間:2022-03-13 格式:DOCX 頁數(shù):18 大?。?2.02KB
收藏 版權(quán)申訴 舉報(bào) 下載
Matlab產(chǎn)生IGES文件代碼【matlab源碼】_第1頁
第1頁 / 共18頁
Matlab產(chǎn)生IGES文件代碼【matlab源碼】_第2頁
第2頁 / 共18頁
Matlab產(chǎn)生IGES文件代碼【matlab源碼】_第3頁
第3頁 / 共18頁

下載文檔到電腦,查找使用更方便

0 積分

下載資源

還剩頁未讀,繼續(xù)閱讀

資源描述:

《Matlab產(chǎn)生IGES文件代碼【matlab源碼】》由會(huì)員分享,可在線閱讀,更多相關(guān)《Matlab產(chǎn)生IGES文件代碼【matlab源碼】(18頁珍藏版)》請(qǐng)?jiān)谘b配圖網(wǎng)上搜索。

1、Matlab產(chǎn)生IGES文件代碼【matlab源碼】畢業(yè)論文,設(shè)計(jì),題目學(xué)院學(xué)院專業(yè)學(xué)生姓名學(xué)號(hào)年級(jí)級(jí)指導(dǎo)教師畢業(yè)教務(wù)處制表畢業(yè)Matlab產(chǎn)生IGES文件代碼一、程序說明本團(tuán)隊(duì)長期從事matlab編程與仿真工作,擅長各類畢業(yè)設(shè)計(jì)、數(shù)據(jù)處理、圖表繪制、理論分析等,程序代做、數(shù)據(jù)分析QQ38782670具體信息聯(lián)系二、程序示例%產(chǎn)生數(shù)據(jù)并寫入iges文件clcclearissearch=2;%0表示只寫點(diǎn),1表示只寫線,2表示點(diǎn)線都寫fprintf(正在寫文件。n);%產(chǎn)生正弦波文件x=0:0.1:10;x=x;y=sin(x);Data=xy;Data(1,3)=0;write_iges(ig

2、es_sin.igs,Data,issearch)%產(chǎn)生peaks文件x,y,z=peaks(30);xx=x(:);yy=y(:);zz=z(:);Data=xxzzyy;write_iges(iges_peaks.igs,Data,issearch)%產(chǎn)生拋物線文件x,y=meshgrid(-1:0.1:1);z=x.A2+y.A2;xx=x(:);yy=y(:);zz=z(:);Data=xxyyzz;write_iges(iges_paowu.igs,Data,issearch)%產(chǎn)生解釋文件xx=10;0;yy=0;10;zz=0;0;Data=xxyyzz;write_iges(i

3、gesforexplain.igs,Data,0)%產(chǎn)生Matlab圖標(biāo)x,y=meshgrid(linspace(-1,1,16);z=membrane;z=z(1:2:end,1:2:end,1:2:end);xx=x(:);yy=y(:);zz=z(:);Data=xxzzyy;write_iges(iges_matlab.igs,Data,issearch)fprintf(寫文件結(jié)束。n);add_start_global函數(shù)文件:%構(gòu)造開始段和全局段字符串functionfilename,file_str=add_start_global(FileName)%開始段信息start=M

4、atlab-IGES-UG,Proe;%全局段信息timedata=clock;Time=sprintf(%4s%2s%2s.%2s%2s%2s,num2str(timedata(1),num2str(timedata(2),num2str(timedata(3),num2str(timedata(4),num2str(timedata(5),num2str(floor(timedata(6);Author=USTCGJ_QSQ;G_1=1H,;G_2=1H;G_3=7HPRT0001;G_4=strcat(num2str(length(FileName),H,FileName);%FileN

5、ameG_5=49HPro/ENGINEERbyParametricTechnologyCorporation;G_6=7H2007170;G_7=32;G_8=38;G_9=7;G_10=38;G_11=15;G_12=7HPRT0001;G_13=1.;G_14=2;G_15=2HMM;G_16=32768;G_17=0.5;G_18=strcat(num2str(length(Time),H,Time);%Time;G_19=0.0865991;G_20=866.025;G_21=strcat(num2str(length(Author),H,Author);%Author;G_22=4

6、HUSTC;G_23=10;G_24=0;G_25=strcat(num2str(length(Time),H,Time);%Time;%構(gòu)造字符串file_str=;%startstart=add_section_index(start,S,1);file_str=strcat(file_str,start,n);%globalrowstr=;count=0;fori=1:25ifi=25temp=strcat(G_,num2str(i),;);elsetemp=strcat(G_,num2str(i),);endiflength(rowstr)+length(temp)>72coun

7、t=count+1;rowstr=add_section_index(rowstr,G,count);file_str=strcat(file_str,rowstr,n);rowstr=temp;elserowstr=strcat(rowstr,temp);ifi=25count=count+1;rowstr=add_section_index(rowstr,G,count);file_str=strcat(file_str,rowstr,n);endendendfilename=FileName;endfunctionresult=add_section_index(str,section,

8、index)result=sprintf(%-72s%s,str,section,index);endwrite_iges函數(shù)文件:%寫igs文件%FileName為寫入的文件名,Data為待寫入的數(shù)據(jù)functionwrite_iges(FileName,Data,PointOrLine)Index=0;%構(gòu)造開始段和全局段字符串filename,file_str=add_start_global(FileName);%構(gòu)造索引段和參數(shù)段ifnargin=2pointorline=2;%0表示只寫點(diǎn),1表示只寫線,2表示點(diǎn)線都寫elsepointorline=PointOrLine;endi

9、fpointorline=0%寫點(diǎn)strDir2strPara2Index=writePoint(Data(1:end,1),Data(1:end,2),Data(1:end,3),Index);file_str=strcat(file_str,strDir2);file_str=strcat(file_str,strPara2);elseifpointorline=1%寫線strDir1strPara1Index=writeLine(Data(1:end-1,1),Data(1:end-1,2),Data(1:end-1,3),Data(2:end,1),Data(2:end,2),Data

10、(2:end,3),Index);file_str=strcat(file_str,strDir1);file_str=strcat(file_str,strPara1);elseifpointorline=2%寫線strDir1strPara1Index=writeLine(Data(1:end-1,1),Data(1:end-1,2),Data(1:end-1,3),Data(2:end,1),Data(2:end,2),Data(2:end,3),Index);file_str=strcat(file_str,strDir1);%寫點(diǎn)strDir2strPara2Index=writeP

11、oint(Data(1:end,1),Data(1:end,2),Data(1:end,3),Index);file_str=strcat(file_str,strDir2);file_str=strcat(file_str,strPara1);file_str=strcat(file_str,strPara2);end%構(gòu)造結(jié)束段str_end=sprintf(%s%s%s%sAs,S,1,G,4,D,2*Index,P,Index,T,1);file_str=strcat(file_str,str_end,n);%寫入文件fid=fopen(FileName,wt);fprintf(fid

12、,file_str);fclose(fid);writeLine函數(shù)文件:%Index為總元素的個(gè)數(shù)functionstrDir,strPara,Index=writeLine(x1,y1,z1,x2,y2,z2,Index)iflength(x1)=length(y1)|length(x1)=length(z1)|length(x2)=length(y2)|length(x2)=length(z2)|length(x2)=length(y1)disp(2了,幾個(gè)線呀);endDirection=struct(type,.%paraPtr,.%version,1,.lineStyle,1,.l

13、ayer,0,.view,0,.matrix,0,.label,0,.status,00000001,.section,D,.type1,.%lineWeight,0,.color,2,.rowNum,1,.form,0,.reserved,.reserved1,.elementLabel,.%elementIndex,.%section1,D.);Line=struct(pointDir,Direction,.x1,.y1,.z1,.x2,.y2,.z2,.ptr,.);count=0;strDir=;strPara=;fori=1:length(x1)count=count+1;Index

14、=Index+1;Line.pointDir.type=110;Line.pointDir.elementLabel=LINE;Line.pointDir.elementIndex=num2str(count);Line.pointDir.paraPtr=num2str(Index);Line.pointDir.type1=Line.pointDir.type;Line.x1=x1;Line.y1=y1;Line.z1=z1;Line.x2=x2;Line.y2=y2;Line.z2=z2;Line.ptr=2*Index-1;%構(gòu)造字符串strDir_temp=sprintf(%8s%8s%

15、8s%8s%8s%8s%8s%8s%8s%sn%8s%8s%8s%8s%8s%8s%8s%8s%8s%s,.Line.pointDir.type,.Line.pointDir.paraPtr,.Line.pointDir.version,.Line.pointDir.lineStyle,.Line.pointDir.layer,.Line.pointDir.view,.Line.pointDir.matrix,.Line.pointDir.label,.Line.pointDir.status,.Line.pointDir.section,2*Index-1,.Line.pointDir.ty

16、pe1,.Line.pointDir.lineWeight,.Line.pointDir.color,.Line.pointDir.rowNum,.Line.pointDir.form,.Line.pointDir.reserved,.Line.pointDir.reserved1,.Line.pointDir.elementLabel,.Line.pointDir.elementIndex,.Line.pointDir.section1,2*Index);strPara_temp=sprintf(%s,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f;,.Line.pointDir

17、.type,.Line.x1(i),.Line.y1(i),.Line.z1(i),.Line.x2(i),.Line.y2(i),.Line.z2(i);strPara_temp=sprintf(%-64s�P%7s,strPara_temp,2*Index-1,Line.pointDir.paraPtr);strDir=strcat(strDir,strDir_temp,n);strPara=strcat(strPara,strPara_temp,n);endwritePoint函數(shù)文件:%Index為總元素的個(gè)數(shù)functionstrDir,strPara,Index=wr

18、itePoint(x,y,z,Index)iflength(x)=length(y)|length(x)=length(z)disp(2了,幾個(gè)點(diǎn)呀);endDirection=struct(type,.%paraPtr,.%version,1,.lineStyle,1,.layer,0,.view,0,.matrix,0,.label,0,.status,00000001,.section,D,.type1,.%lineWeight,0,.color,2,.rowNum,1,.form,0,.reserved,.reserved1,.elementLabel,.%elementIndex,.

19、%section1,D.);Point=struct(pointDir,Direction,.x,.y,.z,.ptr,.);count=0;strDir=;strPara=;fori=1:length(x)count=count+1;Index=Index+1;Point.pointDir.type=116;Point.pointDir.elementLabel=POINT;Point.pointDir.elementIndex=num2str(count);Point.pointDir.paraPtr=num2str(Index);Point.pointDir.type1=Point.po

20、intDir.type;Point.x=x;Point.y=y;Point.z=z;Point.ptr=2*Index-1;%構(gòu)造字符串strDir_temp=sprintf(%8s%8s%8s%8s%8s%8s%8s%8s%8s%sn%8s%8s%8s%8s%8s%8s%8s%8s%8s%s,.Point.pointDir.type,.Point.pointDir.paraPtr,.Point.pointDir.version,.Point.pointDir.lineStyle,.Point.pointDir.layer,.Point.pointDir.view,.Point.pointDi

21、r.matrix,.Point.pointDir.label,.Point.pointDir.status,.Point.pointDir.section,2*Index-1,.Point.pointDir.type1,.Point.pointDir.lineWeight,.Point.pointDir.color,.Point.pointDir.rowNum,.Point.pointDir.form,.Point.pointDir.reserved,.Point.pointDir.reserved1,.Point.pointDir.elementLabel,.Point.pointDir.e

22、lementIndex,.Point.pointDir.section1,2*Index);strPara_temp=sprintf(%s,%.2f,%.2f,%.2f;,.Point.pointDir.type,.Point.x(i),.Point.y(i),.Point.z(i);strPara_temp=sprintf(%-64s?P%7s,strPara_temp,2*Index-1,Point.pointDir.paraPtr);strDir=strcat(strDir,strDir_temp,n);strPara=strcat(strPara,strPara_temp,n);end

23、endwriteColor函數(shù)文件:%Index為總元素的個(gè)數(shù)functionstrDir,strPara,Index=writeColor(r,g,b,Index)iflength(r)=length(g)|length(r)=length(b)disp(2了,幾個(gè)點(diǎn)呀);endDirection=struct(type,.%paraPtr,.%version,1,.lineStyle,1,.layer,0,.view,0,.matrix,0,.label,0,.status,01000200,.section,D,.type1,.%lineWeight,0,.color,2,.rowNum

24、,1,.form,0,.reserved,.reserved1,.elementLabel,.%elementIndex,.%section1,D.);Color=struct(pointDir,Direction,.r,.g,.b,.ptr,.);count=0;strDir=;strPara=;fori=1:length(r)count=count+1;Index=Index+1;Color.pointDir.type=314;Color.pointDir.elementLabel=COLOR;Color.pointDir.elementIndex=num2str(count);Color

25、.pointDir.paraPtr=num2str(Index);Color.pointDir.type1=Color.pointDir.type;Color.r=r;Color.g=g;Color.b=b;Color.ptr=2*Index-1;%構(gòu)造字符串strDir_temp=sprintf(%8s%8s%8s%8s%8s%8s%8s%8s%8s%sn%8s%8s%8s%8s%8s%8s%8s%8s%8s%s,.Color.pointDir.type,.Color.pointDir.paraPtr,.Color.pointDir.version,.Color.pointDir.lineS

26、tyle,.Color.pointDir.layer,.Color.pointDir.view,.Color.pointDir.matrix,.Color.pointDir.label,.Color.pointDir.status,.Color.pointDir.section,2*Index-1,.Color.pointDir.type1,.Color.pointDir.lineWeight,.Color.pointDir.color,.Color.pointDir.rowNum,.Color.pointDir.form,.Color.pointDir.reserved,.Color.poi

27、ntDir.reserved1,.Color.pointDir.elementLabel,.Color.pointDir.elementIndex,.Color.pointDir.section1,2*Index);strPara_temp=sprintf(%s,%.1f,%.1f,%.1f;,.Color.pointDir.type,.Color.r(i),.Color.g(i),.Color.b(i);strPara_temp=sprintf(%-64s�P%7s,strPara_temp,2*Index-1,Color.pointDir.paraPtr);strDir=strcat(strDir,strDir_temp,n);strPara=strcat(strPara,strPara_temp,n);endend

展開閱讀全文
溫馨提示:
1: 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
2: 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
3.本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
5. 裝配圖網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

相關(guān)資源

更多
正為您匹配相似的精品文檔
關(guān)于我們 - 網(wǎng)站聲明 - 網(wǎng)站地圖 - 資源地圖 - 友情鏈接 - 網(wǎng)站客服 - 聯(lián)系我們

copyright@ 2023-2025  zhuangpeitu.com 裝配圖網(wǎng)版權(quán)所有   聯(lián)系電話:18123376007

備案號(hào):ICP2024067431號(hào)-1 川公網(wǎng)安備51140202000466號(hào)


本站為文檔C2C交易模式,即用戶上傳的文檔直接被用戶下載,本站只是中間服務(wù)平臺(tái),本站所有文檔下載所得的收益歸上傳人(含作者)所有。裝配圖網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)上載內(nèi)容本身不做任何修改或編輯。若文檔所含內(nèi)容侵犯了您的版權(quán)或隱私,請(qǐng)立即通知裝配圖網(wǎng),我們立即給予刪除!