magnify matlab源程序.docx

上传人:牧羊曲112 文档编号:3161139 上传时间:2023-03-11 格式:DOCX 页数:7 大小:37.43KB
返回 下载 相关 举报
magnify matlab源程序.docx_第1页
第1页 / 共7页
magnify matlab源程序.docx_第2页
第2页 / 共7页
magnify matlab源程序.docx_第3页
第3页 / 共7页
magnify matlab源程序.docx_第4页
第4页 / 共7页
magnify matlab源程序.docx_第5页
第5页 / 共7页
亲,该文档总共7页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

《magnify matlab源程序.docx》由会员分享,可在线阅读,更多相关《magnify matlab源程序.docx(7页珍藏版)》请在三一办公上搜索。

1、magnify matlab源程序% start of program function magnify(f1)% magnify(f1)% Figure creates a magnification box when under the mouse position when a button is pressed. Press +/- while% button pressed to increase/decrease magnification. Press >/< while button pressed to increase/decrease box size.% Hol

2、d Ctrl while clicking to leave magnification on figure.% Example:% plot(1:100,randn(1,100),(1:300)/3,rand(1,300), grid on,% magnify;if (nargin = 0), f1 = gcf; end;figure(f1); set(f1, .WindowButtonDownFcn, ButtonDownCallback, .WindowButtonUpFcn, ButtonUpCallback, .WindowButtonMotionFcn, ButtonMotionC

3、allback, .KeyPressFcn, KeyPressCallback);return;function ButtonDownCallback(src,eventdata)f1 = src;a1 = get(f1,CurrentAxes);a2 = copyobj(a1,f1);set(f1, .UserData,f1,a1,a2, .Pointer,fullcrosshair, .CurrentAxes,a2);set(a2, .UserData,2,0.2, . %magnification, frame sizeColor,get(a1,Color), .Box,on);xlab

4、el(); ylabel(); zlabel(); title(); set(get(a2,Children), .LineWidth, 2);set(a1, .Color,get(a1,Color)*0.95);set(f1, .CurrentAxes,a1);ButtonMotionCallback(src);return;function ButtonUpCallback(src,eventdata)H = get(src,UserData);f1 = H(1); a1 = H(2); a2 = H(3);set(a1, .Color,get(a2,Color);set(f1, .Use

5、rData, .Pointer,arrow, .CurrentAxes,a1);if strcmp(get(f1,SelectionType),alt),delete(a2);end;return;function ButtonMotionCallback(src,eventdata)H = get(src,UserData);if isempty(H)f1 = H(1); a1 = H(2); a2 = H(3);a2_param = get(a2,UserData);f_pos = get(f1,Position);a1_pos = get(a1,Position);f_cp, a1_cp

6、 = pointer2d(f1,a1);set(a2,Position,(f_cp./f_pos(3:4) 0 0+a2_param(2)*a1_pos(3)*-1 -1 2 2);a2_pos = get(a2,Position);set(a2,XLim,a1_cp(1)+(1/a2_param(1)*(a2_pos(3)/a1_pos(3)*diff(get(a1,XLim)*-0.5 0.5);set(a2,YLim,a1_cp(2)+(1/a2_param(1)*(a2_pos(4)/a1_pos(4)*diff(get(a1,YLim)*-0.5 0.5);end;return;fu

7、nction KeyPressCallback(src,eventdata)H = get(gcf,UserData);if isempty(H)f1 = H(1); a1 = H(2); a2 = H(3);a2_param = get(a2,UserData);if (strcmp(get(f1,CurrentCharacter),+) | strcmp(get(f1,CurrentCharacter),=)a2_param(1) = a2_param(1)*1.2;elseif (strcmp(get(f1,CurrentCharacter),-) | strcmp(get(f1,Cur

8、rentCharacter),_)a2_param(1) = a2_param(1)/1.2;elseif (strcmp(get(f1,CurrentCharacter),<) | strcmp(get(f1,CurrentCharacter),)a2_param(2) = a2_param(2)/1.2;elseif (strcmp(get(f1,CurrentCharacter),>) | strcmp(get(f1,CurrentCharacter),.)a2_param(2) = a2_param(2)*1.2;end;set(a2,UserData,a2_param);Bu

9、ttonMotionCallback(src);end;return;% Included for completeness (usually in own file)function fig_pointer_pos, axes_pointer_val = pointer2d(fig_hndl,axes_hndl)%pointer2d(fig_hndl,axes_hndl)%Returns the coordinates of the pointer (in pixels)%in the desired figure (fig_hndl) and the coordinates% in the

10、 desired axis (axes coordinates)% Example:% figure(1),% hold on,% for i = 1:1000,% figp,axp=pointer2d;% plot(axp(1),axp(2),.,EraseMode,none);% drawnow;% end;% hold off% Rick Hindman - 4/18/01if (nargin = 0), fig_hndl = gcf; axes_hndl = gca; end;if (nargin = 1), axes_hndl = get(fig_hndl,CurrentAxes);

11、 end;set(fig_hndl,Units,pixels);pointer_pos = get(0,PointerLocation);%pixels 0,0 lower leftfig_pos = get(fig_hndl,Position);%pixels l,b,w,hfig_pointer_pos = pointer_pos - fig_pos(1,2);set(fig_hndl,CurrentPoint,fig_pointer_pos);if (isempty(axes_hndl),axes_pointer_val = ;elseif (nargout = 2),axes_pointer_line = get(axes_hndl,CurrentPoint);axes_pointer_val = sum(axes_pointer_line)/2;end;% end of program

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 生活休闲 > 在线阅读


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号