您好,欢迎访问三七文档
当前位置:首页 > 财经/贸易 > 资产评估/会计 > 莫尔条纹matlab模拟
functionMoire_pattern_simglobaldt%dt是鼠标每次移动绕旋转中心转动角度的增量N=25;%numberoflinesh_f=figure;h_a=axes('parent',h_f);set(h_f,...'windowbuttonupfcn',@stopdragfcn,...'windowbuttonmotionfcn','')%先将figure的鼠标移动的callback设为空,鼠标(按下后)弹起的callback设为stopdragfcn函数set(h_a,'buttondownfcn',@startdragfcn)%将axes的鼠标按下的callback设为startdragfcn函数set(h_a,'dataaspectratio',[111],...'xlim',[-2,2],'ylim',[-2,2])%mouse_down=false;xy_pre=[NaN,NaN];%存储鼠标移动前上一次的坐标rt_pt=[00];%旋转中心rt_mat=repmat(rt_pt',1,2*N);%计算变换后坐标时要用t=0;%t为旋转角度x0=repmat(linspace(-1,1,N),2,1);%在图上不动的N条线的x坐标y0=repmat([-1;1],1,N);x1=x0;%旋转运动的N条线的x坐标y1=y0;l1=zeros(1,N);%运动线条的句柄fork=1:Nline(x0(:,k),y0(:,k),'color',[0,0,0],'linestyle','-',...'linewidth',2);l1(k)=line(x1(:,k),y1(:,k),'color',[0,0,0],'linestyle','-',...'linewidth',2);end%产生2N条线functionstartdragfcn(varargin)%mouse_down=true;set(h_f,'windowbuttonmotionfcn',@draggingfcn)pt=get(h_a,'currentpoint');xy_pre=pt(1,1:2);endfunctionstopdragfcn(varargin)%mouse_down=false;set(h_f,'windowbuttonmotionfcn','')endfunctiondraggingfcn(varargin)%ifmouse_downpt=get(h_a,'currentpoint');v1=xy_pre-rt_pt;v2=pt(1,1:2)-rt_pt;xy_pre=pt(1,1:2);dt=atan2(v2(2),v2(1))-atan2(v1(2),v1(1));t=t+dt;t=t/2;A=[cos(t),-sin(t);sin(t),cos(t)];xy1=A*([[x1(1,:),x1(2,:)];[y1(1,:),y1(2,:)]]-rt_mat)+rt_mat;x1=[xy1(1,1:N);xy1(1,N+1:2*N)];y1=[xy1(2,1:N);xy1(2,N+1:2*N)];forkk=1:Nset(l1(kk),...'xdata',x1(:,kk),...'ydata',y1(:,kk));end%endendend
本文标题:莫尔条纹matlab模拟
链接地址:https://www.777doc.com/doc-7644133 .html