在这里http://forum.simwe.com/viewthread.php?tid=880867&page=1#pid1824705
看到这个, 觉得好玩, 转来与大家共同欣赏!-
- function chgicon(hfig,iconfile)
- %CHGICON changes the Figure HFIG's icon to the icon specified by ICONFILE
- % HFIG must be a figure handle.
- % ICONFILE is a string specifies the path to an imagefile.
- %
- %WARNING:
- % Changing the matlab icon violate the mathworks license. THis function can
- % only be used for study purpose. Please delete it within 24 hours.
- %
- % Author: junziyang (simwer@126.com)
- % Ver.1.0
- % 2009-05-20
- error(nargchk(2,2,nargin));
- if ~ishandle(hfig) && ~isequal(get(hfig,'Type'),'figure')
- error('The first input argument must be a Figure handle.');
- end
- if ~ischar(iconfile) || ~exist(iconfile,'file')
- error('Icon file name is not input properly.');
- end
- mde = com.mathworks.mde.desk.MLDesktop.getInstance;
- if isequal(get(hfig,'NumberTitle'),'off') && isempty(get(hfig,'Name'))
- figTag = 'junziyang'; %Name the figure temporarily
- set(hfig,'Name',figTag);
- elseif isequal(get(hfig,'NumberTitle'),'on') && isempty(get(hfig,'Name'))
- figTag = ['Figure ',num2str(hfig)];
- elseif isequal(get(hfig,'NumberTitle'),'off') && ~isempty(get(hfig,'Name'))
- figTag = get(hfig,'Name');
- else
- figTag = ['Figure ',num2str(hfig),': ',get(hfig,'Name')];
- end
- drawnow %Update figure window
- jfig = mde.getClient(figTag); %Get the underlying JAVA object of the figure.
- jfig.setClientIcon(javax.swing.ImageIcon(iconfile));
- if isequal(get(hfig,'Name'),'junziyang')
- set(hfig,'Name',''); %Delete the temporary figure name
- end
复制代码
月初即想转贴, 并询问友网是否允许转贴!
已经版主同意, 但想若经楼主同意好像更尊重些, 一等一忙竟给忘记了!
刚在中文又看到http://www_ilovematlab_cn/viewthread.php?tid=57132&page=1#pid532336 (change "_" to ".")
不知是否为原创者, 但肯定是旧版!
怕再次忘记, 先贴了
[ 本帖最后由 ChaChing 于 2010-5-21 18:18 编辑 ] |