您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 企业财务 > 数控技术-直线插补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);
本文标题:数控技术-直线插补matlab
链接地址:https://www.777doc.com/doc-5255965 .html