数控技术-直线插补matlab

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

------------------------doitbyyourself!CUPfunctionPath_pushbutton_Callback(hObject,eventdata,handles)%hObjecthandletoPath_pushbutton(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)a=str2num(get(handles.Begin_edittext,'String'));%strnum±íʾÊý×éÓÉ×Ö·ûÐÍת»»³ÉÊý×ÖÐÍb=str2num(get(handles.Termin_edittext,'String'));h=str2num(get(handles.Length_Edittext,'String'));%±íʾ²½³¤x=[a(1),b(1)];%Ï൱ÓÚ[x0,xe]y=[a(2),b(2)];%¸ã°ëÌìÖ»ÒªÕâÑù¾Í¿ÉÒÔÁËߣ¬ÍÛ¹þ¹þaxes(handles.axes1);plot(x,y);holdon;Xe=x(2)-x(1);Ye=y(2)-y(1);NXY=(abs(Xe)+abs(Ye))/h;%set(handles.Display_edittext,'Max',NXY);step=0;Fm=0;Xm=x(1);Ym=y(1);XOY=1;if((Xe0)&(Ye=0))XOY=1;endif((Xe=0)&(Ye0))XOY=2;endif((Xe0)&(Ye=0))XOY=3;endif((Xe0)&(Ye0))XOY=4;endset(handles.Display_edittext,'String',num2str(XOY));%ÔÝÇÒÆð¸öÏÔʾ×÷ÓÃholdonwhile(stepNXY)switchXOYcase1title(['µÚÒ»ÏóÏÞÖ±Ï߲岹'])if(Fm=0)x1=[Xm,Xm+h];y1=[Ym,Ym];elsex1=[Xm,Xm];y1=[Ym,Ym+h];endcase2title(['µÚ¶þÏóÏÞÖ±Ï߲岹'])if(Fm0)x1=[Xm,Xm-h];y1=[Ym,Ym];elsex1=[Xm,Xm];y1=[Ym,Ym+h];endcase3title(['µÚÈýÏóÏÞÖ±Ï߲岹'])if(Fm=0)x1=[Xm,Xm-h];y1=[Ym,Ym];elsex1=[Xm,Xm];y1=[Ym,Ym-h];endcase4title(['µÚËÄÏóÏÞÖ±Ï߲岹'])if(Fm0)x1=[Xm,Xm+h];y1=[Ym,Ym];elsex1=[Xm,Xm];y1=[Ym,Ym-h];endendstep=step+1;plot(x1,y1,'b-');holdonXm=x1(2);%±£´æ´Ëµã×ø±ê¹©Ï´Î×÷ͼºÍ±È½ÏʱʹÓÃYm=y1(2);Fm=(Ym-y(1))*Xe-(Xm-x(1))*Ye;holdon;%xlwrite('data.xls',2,3)%text((x1(1)+x1(2))/2,(y1(1)+y1(2))/2,[num2str(step)])pause(0.5);%ÑÓʱ³ÌÐòÐβÎΪÿ×ßÒ»²½ËùÓÃʱ¼äendxlabel('X')ylabel('Y')%holdoff;handles.output=hObject;guidata(hObject,handles);\\\\\|||||||functionClear_Callback(hObject,eventdata,handles)%hObjecthandletoClear(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%cla(handles.axes1);clareset;guidata(hObject,handles);

1 / 3
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功