完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
`总是想修改matlab中figure左上角的logo图标,让自己赏心悦目一点。。。比如我用下面这个卡通人物 转换后的效果如下图: 这样就能使用自己的QQ头像或者照片来作为自己作品的标志了。具体实现方法,其实十分简单,只需要一个函数chgicon.m 该函数用红色文字表示: function chgicon(h,filename) %CHGICON changes the figure icon. % CHGICON(H,FILENAME) changes the icon of a figure to an image specified by % the string FILENAME, where H is a handle to the figure. If the file is not % in the current directory or in a directory in the MATLAB path,specify the % full pathname of the location on your system. If FILENAME is not a valid % image file name, the function just removes the previous icon of the figure. % % Example: % h = figure; % chgicon(h,'newIcon.png'); % replace 'newIcon.png' with your image % % IMPORTANT NOTES: % REPLACING THE MATLAB GUI ICON VIOLATES THE LICENSE AGREEMENT % OF MATLAB. DO NOT USE THIS FUNCTION COMMERCIALLY. % % Han Qun, Sept. 2005 % Copyright 2005-2006 Han Qun % College of Precision Instrument and Opto-Electronics Engineering, % Tianjin University, 300072, P.R.China. % Email: junziyang@126.com % $Revision: 1.0 $ $Date: 2005/12/2 $ if nargin<2 error('MATLAB:chgicon','%s','Too few input arguments!'); end if nargin >2 error('MATLAB:chgicon','%s','Too many input arguments!'); end newIcon = javax.swing.ImageIcon(filename); javaFrame = get(h,'JavaFrame'); javaFrame.setFigureIcon(newIcon); 将上面的函数保存在自己要使用的路径下,再调用即可。 调用语句: h = figure chgicon(h,'12.jpg'); 就可以了。 再推广到GUI上也是一样的,只要在Create Fcn中调用这个函数就可以了: function figure1_CreateFcn(hObject, eventdata, handles) % hObject handle to figure1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called chgicon(hObject,'12.jpg'); 结果也是很成功: |
|
相关推荐
|
|
1533 浏览 1 评论
200圆!求助大佬给一份VSG并网和离网模式的simulink仿真
1817 浏览 0 评论
MATLAB(3)--矩阵的引用(sub2ind、ind2sub、reshape函数使用)
2634 浏览 0 评论
2970 浏览 0 评论
4094 浏览 1 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-22 06:03 , Processed in 0.427251 second(s), Total 69, Slave 51 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号