您的位置:首页 > 编程语言 > MATLAB

Matlab薛定谔方程工具箱系列——GUI初步美化

2014-03-28 16:50 429 查看
                                                                                                                                                                                                                                                                

                                                                                                                                                                                                                                                                

 

这是我在Github建立的SCHRODINGER工具箱的技术记录。

这一个工具箱原本是1999年发布的,已经有了很久的历史的,现在界面看起来也很老,功能也需要更新一下。正好我在上量子力学课,就来做做。

原作者的链接:

http://www.theophys.kth.se/mathphys/schrodinger.html

现在我建立的链接:

Rareson/SCHRODINGER
https://github.com/Rareson/SCHRODINGER/

                                                                                                                                                                                                                                                                

                                                                                                                                                                                                                                                                

这次先在配色上进行初步变化。

以前的界面是这样的:



按钮上的字几乎看不见。。。。。

使用GUIDE进行编辑,然后自动生成代码,产生界面如下:



代码是(注意如果要让按钮起作用,得下完整的工具箱):

function h1 = main_gui_export()
% This is the machine-generated representation of a Handle Graphics object
% and its children.  Note that handle values may change when these objects
% are re-created. This may cause problems with any callbacks written to
% depend on the value of the handle at the time the object was saved.
% This problem is solved by saving the output as a FIG-file.
%
% To reopen this object, just type the name of the M-file at the MATLAB
% prompt. The M-file and its associated MAT-file must be on your path.
%
% NOTE: certain newer features in MATLAB may not have been saved in this
% M-file due to limitations of this format, which has been superseded by
% FIG-files.  Figures which have been annotated using the plot editor tools
% are incompatible with the M-file/MAT-file format, and should be saved as
% FIG-files.

appdata = [];
appdata.FileMenuFcnLastExportedAsType = 5;
appdata.GUIDEOptions = struct(...
'active_h', [], ...
'taginfo', [], ...
'override', 0, ...
'release', 12, ...
'resize', 'simple', ...
'accessibility', 'on', ...
'mfile', 0, ...
'callbacks', [], ...
'singleton', [], ...
'syscolorfig', [], ...
'blocking', 0, ...
'lastFilename', 'C:\Users\Administrator\Desktop\SCHRODINGER-rareson\main_gui.fig');
appdata.lastValidTag = blanks(0);
appdata.GUIDELayoutEditor = [];
appdata.initTags = struct(...
'handle', [], ...
'tag', 'figMenuHelp');

h1 = figure(...
'PaperUnits',get(0,'defaultfigurePaperUnits'),...
'Color',[0.941176470588235 0.941176470588235 0.941176470588235],...
'Colormap',get(0,'defaultfigureColormap'),...
'InvertHardcopy',get(0,'defaultfigureInvertHardcopy'),...
'PaperPosition',[0.6345175 6.345175 20.30456 15.22842],...
'PaperSize',get(0,'defaultfigurePaperSize'),...
'PaperType',get(0,'defaultfigurePaperType'),...
'Position',get(0,'defaultfigurePosition'),...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

appdata = [];
appdata.lastValidTag = blanks(0);

h2 = axes(...
'Parent',h1,...
'CameraPosition',[0.5 0.5 9.16025403784439],...
'CameraPositionMode',get(0,'defaultaxesCameraPositionMode'),...
'Color',get(0,'defaultaxesColor'),...
'ColorOrder',get(0,'defaultaxesColorOrder'),...
'LooseInset',[0.13 0.11 0.095 0.075],...
'XColor',get(0,'defaultaxesXColor'),...
'XLim',get(0,'defaultaxesXLim'),...
'XLimMode','manual',...
'YColor',get(0,'defaultaxesYColor'),...
'YLim',get(0,'defaultaxesYLim'),...
'YLimMode','manual',...
'ZColor',get(0,'defaultaxesZColor'),...
'Visible','off',...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

h3 = get(h2,'title');

set(h3,...
'Parent',h2,...
'Units','data',...
'FontUnits','points',...
'BackgroundColor','none',...
'Color',[0 0 0],...
'DisplayName',blanks(0),...
'EdgeColor','none',...
'EraseMode','normal',...
'DVIMode','auto',...
'FontAngle','normal',...
'FontName','Helvetica',...
'FontSize',24,...
'FontWeight','normal',...
'HorizontalAlignment','center',...
'LineStyle','-',...
'LineWidth',0.5,...
'Margin',2,...
'Position',[0.498847926267281 1.01963746223565 1.00005459937205],...
'Rotation',0,...
'String','Welcome to Schrodinger!',...
'Interpreter','tex',...
'VerticalAlignment','bottom',...
'ButtonDownFcn',[],...
'CreateFcn', {@local_CreateFcn, [], ''} ,...
'DeleteFcn',[],...
'BusyAction','queue',...
'HandleVisibility','off',...
'HelpTopicKey',blanks(0),...
'HitTest','on',...
'Interruptible','on',...
'SelectionHighlight','on',...
'Serializable','on',...
'Tag',blanks(0),...
'UserData',[],...
'Visible','on',...
'XLimInclude','on',...
'YLimInclude','on',...
'ZLimInclude','on',...
'CLimInclude','on',...
'ALimInclude','on',...
'IncludeRenderer','on',...
'Clipping','off');

h4 = get(h2,'xlabel');

set(h4,...
'Parent',h2,...
'Units','data',...
'FontUnits','points',...
'BackgroundColor','none',...
'Color',[0 0 0],...
'DisplayName',blanks(0),...
'EdgeColor','none',...
'EraseMode','normal',...
'DVIMode','auto',...
'FontAngle','normal',...
'FontName','Helvetica',...
'FontSize',10,...
'FontWeight','normal',...
'HorizontalAlignment','center',...
'LineStyle','-',...
'LineWidth',0.5,...
'Margin',2,...
'Position',[0.498847926267281 -0.0709969788519638 1.00005459937205],...
'Rotation',0,...
'String',blanks(0),...
'Interpreter','tex',...
'VerticalAlignment','cap',...
'ButtonDownFcn',[],...
'CreateFcn', {@local_CreateFcn, [], ''} ,...
'DeleteFcn',[],...
'BusyAction','queue',...
'HandleVisibility','off',...
'HelpTopicKey',blanks(0),...
'HitTest','on',...
'Interruptible','on',...
'SelectionHighlight','on',...
'Serializable','on',...
'Tag',blanks(0),...
'UserData',[],...
'Visible','off',...
'XLimInclude','on',...
'YLimInclude','on',...
'ZLimInclude','on',...
'CLimInclude','on',...
'ALimInclude','on',...
'IncludeRenderer','on',...
'Clipping','off');

h5 = get(h2,'ylabel');

set(h5,...
'Parent',h2,...
'Units','data',...
'FontUnits','points',...
'BackgroundColor','none',...
'Color',[0 0 0],...
'DisplayName',blanks(0),...
'EdgeColor','none',...
'EraseMode','normal',...
'DVIMode','auto',...
'FontAngle','normal',...
'FontName','Helvetica',...
'FontSize',10,...
'FontWeight','normal',...
'HorizontalAlignment','center',...
'LineStyle','-',...
'LineWidth',0.5,...
'Margin',2,...
'Position',[-0.065668202764977 0.496978851963746 1.00005459937205],...
'Rotation',90,...
'String',blanks(0),...
'Interpreter','tex',...
'VerticalAlignment','bottom',...
'ButtonDownFcn',[],...
'CreateFcn', {@local_CreateFcn, [], ''} ,...
'DeleteFcn',[],...
'BusyAction','queue',...
'HandleVisibility','off',...
'HelpTopicKey',blanks(0),...
'HitTest','on',...
'Interruptible','on',...
'SelectionHighlight','on',...
'Serializable','on',...
'Tag',blanks(0),...
'UserData',[],...
'Visible','off',...
'XLimInclude','on',...
'YLimInclude','on',...
'ZLimInclude','on',...
'CLimInclude','on',...
'ALimInclude','on',...
'IncludeRenderer','on',...
'Clipping','off');

h6 = get(h2,'zlabel');

set(h6,...
'Parent',h2,...
'Units','data',...
'FontUnits','points',...
'BackgroundColor','none',...
'Color',[0 0 0],...
'DisplayName',blanks(0),...
'EdgeColor','none',...
'EraseMode','normal',...
'DVIMode','auto',...
'FontAngle','normal',...
'FontName','Helvetica',...
'FontSize',10,...
'FontWeight','normal',...
'HorizontalAlignment','right',...
'LineStyle','-',...
'LineWidth',0.5,...
'Margin',2,...
'Position',[-0.169354838709677 1.12537764350453 1.00005459937205],...
'Rotation',0,...
'String',blanks(0),...
'Interpreter','tex',...
'VerticalAlignment','middle',...
'ButtonDownFcn',[],...
'CreateFcn', {@local_CreateFcn, [], ''} ,...
'DeleteFcn',[],...
'BusyAction','queue',...
'HandleVisibility','off',...
'HelpTopicKey',blanks(0),...
'HitTest','on',...
'Interruptible','on',...
'SelectionHighlight','on',...
'Serializable','on',...
'Tag',blanks(0),...
'UserData',[],...
'Visible','off',...
'XLimInclude','on',...
'YLimInclude','on',...
'ZLimInclude','on',...
'CLimInclude','on',...
'ALimInclude','on',...
'IncludeRenderer','on',...
'Clipping','off');

appdata = [];
appdata.lastValidTag = blanks(0);

h7 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'BackgroundColor',[0.9 0.9 0.9],...
'FontSize',9,...
'HorizontalAlignment','left',...
'Position',[0.15 0.45 0.75 0.45],...
'String',{  ' This set of MATLAB programs solves the Schroedinger equation, '; ' in 1D, for a choice of potentials and boundary conditions. '; ' The methods used are: numerical integration and adaption to boundary  '; ' conditions, solving the time-dependent equation by iteration, matrix '; ' approximation using a discrete basis, expansion in special functions.'; '               '; ' There are a number of nonstandard routines for finding eigenvalues '; ' from the numerical integrations. Read the manual and the m-files to '; ' learn the basics and the technical tricks. In many of the examples '; ' you must know the relevant energy scales in order to set values of '; ' the parameters which will give interesting results. ' },...
'Style','text',...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

appdata = [];
appdata.lastValidTag = blanks(0);

h8 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'BackgroundColor',[0.152941176470588 0.227450980392157 0.372549019607843],...
'Callback','close;integrat',...
'FontSize',12,...
'ForegroundColor',[0.870588235294118 0.92156862745098 0.980392156862745],...
'Position',[0.15 0.38 0.35 0.06],...
'String','Numerical integration',...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

appdata = [];
appdata.lastValidTag = blanks(0);

h9 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'BackgroundColor',[0.152941176470588 0.227450980392157 0.372549019607843],...
'Callback','close; inbox;',...
'FontSize',12,...
'ForegroundColor',[0.870588235294118 0.92156862745098 0.980392156862745],...
'Position',[0.15 0.31 0.35 0.06],...
'String','Particle in a box',...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

appdata = [];
appdata.lastValidTag = blanks(0);

h10 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'BackgroundColor',[0.152941176470588 0.227450980392157 0.372549019607843],...
'Callback','close;wavepac',...
'FontSize',12,...
'ForegroundColor',[0.870588235294118 0.92156862745098 0.980392156862745],...
'Position',[0.15 0.24 0.35 0.06],...
'String','Wave packets',...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

appdata = [];
appdata.lastValidTag = blanks(0);

h11 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'BackgroundColor',[0.152941176470588 0.227450980392157 0.372549019607843],...
'Callback','close;boundst',...
'FontSize',12,...
'ForegroundColor',[0.870588235294118 0.92156862745098 0.980392156862745],...
'Position',[0.15 0.17 0.35 0.06],...
'String','Bound states',...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

appdata = [];
appdata.lastValidTag = blanks(0);

h12 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'BackgroundColor',[0.152941176470588 0.227450980392157 0.372549019607843],...
'Callback','close;per1d',...
'FontSize',12,...
'ForegroundColor',[0.870588235294118 0.92156862745098 0.980392156862745],...
'Position',[0.15 0.1 0.35 0.06],...
'String','Periodic potentials',...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

appdata = [];
appdata.lastValidTag = blanks(0);

h13 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'BackgroundColor',[0.152941176470588 0.227450980392157 0.372549019607843],...
'Callback','close;scatt',...
'FontSize',12,...
'ForegroundColor',[0.870588235294118 0.92156862745098 0.980392156862745],...
'Position',[0.55 0.38 0.35 0.06],...
'String','Scattering in 1D',...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

appdata = [];
appdata.lastValidTag = blanks(0);

h14 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'BackgroundColor',[0.152941176470588 0.227450980392157 0.372549019607843],...
'Callback','close;scatt3d',...
'FontSize',12,...
'ForegroundColor',[0.870588235294118 0.92156862745098 0.980392156862745],...
'Position',[0.55 0.31 0.35 0.06],...
'String','Scattering in 2D and 3D',...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

appdata = [];
appdata.lastValidTag = blanks(0);

h15 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'BackgroundColor',[0.152941176470588 0.227450980392157 0.372549019607843],...
'Callback','close;special',...
'FontSize',12,...
'ForegroundColor',[0.870588235294118 0.92156862745098 0.980392156862745],...
'Position',[0.55 0.24 0.35 0.06],...
'String','Special functions',...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

appdata = [];
appdata.lastValidTag = blanks(0);

h16 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'BackgroundColor',[0.152941176470588 0.227450980392157 0.372549019607843],...
'Callback','close;hatom',...
'FontSize',12,...
'ForegroundColor',[0.870588235294118 0.92156862745098 0.980392156862745],...
'Position',[0.55 0.17 0.35 0.06],...
'String','Hydrogen atom',...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

appdata = [];
appdata.lastValidTag = blanks(0);

h17 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'BackgroundColor',[0 0 0.9],...
'Callback','close',...
'FontSize',12,...
'ForegroundColor',[0.870588235294118 0.92156862745098 0.980392156862745],...
'Position',[0.55 0.1 0.35 0.06],...
'String','QUIT',...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

% --- Set application data first then calling the CreateFcn.
function local_CreateFcn(hObject, eventdata, createfcn, appdata)

if ~isempty(appdata)
names = fieldnames(appdata);
for i=1:length(names)
name = char(names(i));
setappdata(hObject, name, getfield(appdata,name));
end
end

if ~isempty(createfcn)
if isa(createfcn,'function_handle')
createfcn(hObject, eventdata);
else
eval(createfcn);
end
end

 

 

 

 

 

 

 

 

 

MATLAB GUI 去除界面边框的方法等_ZarkCloud_新浪博客
http://blog.sina.com.cn/s/blog_598e352501017iqb.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  github matlab