?? t_youhua.m
字號:
T_SimulationData = [] ;
try
load( SaveFile, 'T_SimulationData' ) ;
catch
end
if isempty( T_SimulationData ) | ~isstruct( T_SimulationData );
warndlg( WarningString1, '警告', 'modal' ) ;
return ;
end
% save the data .
setappdata( handles.T_youhua, 'T_SimulationData', T_SimulationData ) ;
% --------------------------------------------------------------------------
function BeginButton_Callback( h )
handles = guidata( h ) ;
% get the T_SimulationData .
T_SimulationData = getappdata( handles.T_youhua, 'T_SimulationData' ) ;
% open the parameter figure .
% EditParameter( T_SimulationData ) ;
CalculateStatusEquation( T_SimulationData ) ;
% close the current figure .
pause(0) ;
close( handles.T_youhua ) ;
% --------------------------------------------------------------------------
function MenuHelp_Callback( h )
handles = guidata( h ) ;
try
% get the current path .
CurrentPath = cd ;
HelpFileName = fullfile( CurrentPath, 'T_SimulationHelp.pdf' ) ;
% open the help file .
mexrun( HelpFileName ) ;
catch
% get the current path .
CurrentPath = cd ;
HelpFileName = fullfile( CurrentPath, 'T_SimulationHelp.doc' ) ;
% open the help file .
mexrun( HelpFileName ) ;
end
% --------------------------------------------------------------------------
function MenuDemo_Callback( h )
handles = guidata( h ) ;
% open the demo .
T_SoftDemo ;
% --------------------------------------------------------------------------
function MenuAbout_Callback( h )
handles = guidata( h ) ;
% find if have the same figure, and close it .
OldFigure = findobj( 'type', 'figure', 'Tag', 'AboutT_Simulation' ) ;
if ishandle( OldFigure )
close( OldFigure ) ;
end
% init the variables .
FigureWidth = 250 ;
FigureHeight = 220 ;
TabSpace = 10 ;
TextHeight = 20 ;
% generate a new figure .
FigureHandle = figure( 'Visible', 'off' ) ;
set( FigureHandle, 'Units' , 'pixels', 'Position', [150 150 FigureWidth FigureHeight], ...
'Name', '關(guān)于', 'Tag', 'AboutT_Simulation', 'FileName' , '' ,...
'MenuBar' , 'none', 'NumberTitle' , 'off' ,...
'Resize', 'off', 'windowstyle', 'normal', 'Visible', 'off' ) ;
movegui( FigureHandle, 'center' )
% generate the axes to plot lines .
AxesHandle = axes( 'Parent', FigureHandle, 'Units' , 'normalized' , ...
'Position', [0 0 1 1], 'Visible', 'off', ...
'Xlim', [0 FigureWidth], 'Ylim', [0 FigureHeight] ) ;
% get the color of the figure .
FigureColor = get( FigureHandle, 'Color' ) ;
% reset the default value of the uicontrols .
set(FigureHandle,'defaultuicontrolunits','normalized');
set(FigureHandle,'defaultuicontrolfontname','隸書');
set(FigureHandle,'defaultuicontrolBackgroundColor', FigureColor );
% -----------------------------------------------------------------------------
% define the first frame .
FrameXPos = TabSpace * 2 ;
FrameWidth = FigureWidth - TabSpace * 4 ;
FrameHeight = FigureHeight - TabSpace * 8 ;
FrameYPos = FigureHeight - FrameHeight - TabSpace * 2 ;
Frame1Position = [FrameXPos FrameYPos FrameWidth FrameHeight] ;
% generate a frame .
TitleHandle = uicontrol(FigureHandle,'style','frame', 'Units','pixels',...
'position',Frame1Position );
TextXPos = Frame1Position(1) + TabSpace ;
TextYPos = Frame1Position(2) + TabSpace ;
TextWidth = Frame1Position(3) - TabSpace * 2 ;
TextHeight = Frame1Position(4) - TabSpace * 2 ;
TextPosition = [TextXPos TextYPos TextWidth TextHeight] ;
% subtitle:
TextHandle = uicontrol(FigureHandle, 'Style','text', 'Units','pixels',...
'position',TextPosition, 'Horizontal','left',...
'string', {[' 《T型自卸汽車優(yōu)化分析軟件》是一個完全由matlab實(shí)現(xiàn)的軟件。']}, 'fontsize',13 );
ButtonWidth = 80 ;
ButtonHeight = 25 ;
ButtonXPos = FigureWidth - ButtonWidth - TabSpace * 3 ;
ButtonYPos = TabSpace * 2 ;;
ButtonPosition = [ButtonXPos ButtonYPos ButtonWidth ButtonHeight] ;
% generate the pushbutton: Close .
ButtonHandle = uicontrol( 'Parent', FigureHandle, 'Units', 'Pixels', 'Position', ButtonPosition, ...
'Style', 'pushbutton', 'string', '關(guān)閉', 'Fontsize',12, 'Callback', ['close(gcbf) ;'] ) ;
% display the figure .
set( FigureHandle, 'Visible', 'on' ) ;
%--------------------------------------------
function micintro %制作動畫
authorzname='歡迎使用';
MatlabCentral='作者:崔林林 ';
url='cuill112@sohu.com';
%這三個顯示的內(nèi)容可以改變的
ax=axes(...
'layer','bottom','units','norm',...
'position',[0 0 1 1],...
'xtick',[],'ytick',[],...
'color',[0.8 0.8 1]...
);
h1=letterzoom(authorzname,0.7,0.3,0.7,0.1,'k'); %letterzoom為設(shè)置位置及顏色
h2=letterzoom(MatlabCentral,0.55,0.15,0.85,0.12,'k');
h3=letterzoom(url,0.4,0.1,0.9,0.04,'b');
pause(1.5)
s=get(gcf,'userdata');
%sound(s.y1,s.fs)
scatterletters([h1 h2 h3])
delete(ax)
function scatterletters(h)
n=length(h);
finalx=rand(1,n)-0.5;
finaly=rand(1,n)-0.5;
finalx=finalx+0.5.*sign(finalx)+0.5;
finaly=finaly+0.5.*sign(finaly)+0.5;
stepz=20;
for j=1:n,
pos=get(h(j),'pos');
x=pos(1); y=pos(2);
d(j,:)=[(finalx(j)-x)/stepz (finaly(j)-y)/stepz];
end
moveletters(h,d,stepz)
function h=letterzoom(string,height,xleft,xright,fontsize,color); %letterzoom為設(shè)置位置及顏色
n=length(string);
finalx=linspace(xleft,xright,n);
finaly=finalx.*0+height;
stepz=20;
for j=1:n,
x=rand;
y=rand;
if x<0.5,x=x-0.5;else x=x+0.5;end %設(shè)置位置
if y<0.5,y=y-0.5;else y=y+0.5;end
h(j)=text(x,y,string(j),...
'fontunits','normalized',...
'fontsize',fontsize,...
'color',color,...
'fontname','Courier New',...
'fontweight','bold',...
'HorizontalAlignment','center',...
'erasemode','xor');
d(j,:)=[(finalx(j)-x)/stepz (finaly(j)-y)/stepz];
end
axis([0 1 0 1]);
moveletters(h,d,stepz);
function moveletters(h,d,stepz) %片頭字體的移動
n=length(h);
for j=1:stepz,
for k=1:n,
currentPos=get(h(k),'position');
currentPos(1:2)=currentPos(1:2)+d(k,:);
set(h(k),'position',currentPos)
end
pause(1/stepz)
end
%--------------------------------------------------------------------------
function shizhong(h)
handles = guidata( h ) ;
% find if have the same figure, and close it .
OldFigure = findobj( 'type', 'figure', 'Tag', 'hfig' ) ;
if ishandle( OldFigure )
close( OldFigure ) ;
end
try
hfig=figure('position',[700 100 250 250]); ;
set(hfig,'NumberTitle','off');
set(hfig,'name','顯示當(dāng)前時間的表');
set(hfig,'MenuBar','none');
set(hfig,'color',[0.5 0.7 0.3])
A=linspace(0,6.3,1000);
x1=8*cos(A);
y1=8*sin(A);
x2=7*cos(A);
y2=7*sin(A);
plot(x1,y1,'b','linewidth',1.4)
hold on
plot(x2,y2,'b','linewidth',3.5)
fill(0.4*cos(A),0.4*sin(A),'r');
axis off
axis([-10 10 -10 10])
axis equal
set(gca,'position',[[0.13 0.05 0.775 0.815]])
title(date,'fontsize',18)
for k=1:12;
xk=9*cos(-2*pi/12*k+pi/2);
yk=9*sin(-2*pi/12*k+pi/2);
plot([xk/9*8 xk/9*7],[yk/9*8 yk/9*7],'color',[0.3 0.8 0.9])
% if k
h=text(xk,yk,num2str(k),'fontsize',16,'color',...
[0.9 0.3 0.8],'HorizontalAlignment','center');
end
% 計(jì)算時針位置
ti=clock;
th=-(ti(4)+ti(5)/60+ti(6)/3600)/12*2*pi+pi/2;
xh3=4.0*cos(th);
yh3=4.0*sin(th);
xh2=xh3/2+0.5*cos(th-pi/2);
yh2=yh3/2+0.5*sin(th-pi/2);
xh4=xh3/2-0.5*cos(th-pi/2);
yh4=yh3/2-0.5*sin(th-pi/2);
hh=fill([0 xh2 xh3 xh4 0],[0 yh2 yh3 yh4 0],[0.6 0.5 0.3]);
% 計(jì)算分針位置
tm=-(ti(5)+ti(6)/60)/60*2*pi+pi/2;
xm3=6.0*cos(tm);
ym3=6.0*sin(tm);
xm2=xm3/2+0.5*cos(tm-pi/2);
ym2=ym3/2+0.5*sin(tm-pi/2);
xm4=xm3/2-0.5*cos(tm-pi/2);
ym4=ym3/2-0.5*sin(tm-pi/2);
hm=fill([0 xm2 xm3 xm4 0],[0 ym2 ym3 ym4 0],[0.6 0.5 0.3]);
% 計(jì)算秒針位置
ts=-(ti(6))/60*2*pi+pi/2;
hs=plot([0 7*cos(ts)],[0 7*sin(ts)],...
'color',[0.6 0.5 0.3],'linewidth',3);
set(gcf,'doublebuffer','on');
k=1;
while k<6;
ti=clock;
% 計(jì)算時針位置
th=-(ti(4)+ti(5)/60+ti(6)/3600)/12*2*pi+pi/2;
xh3=4.0*cos(th);
yh3=4.0*sin(th);
xh2=xh3/2+0.5*cos(th-pi/2);
yh2=yh3/2+0.5*sin(th-pi/2);
xh4=xh3/2-0.5*cos(th-pi/2);
yh4=yh3/2-0.5*sin(th-pi/2);
set(hh,'XData',[0 xh2 xh3 xh4 0],'YData',[0 yh2 yh3 yh4 0])
% 計(jì)算分針位置
tm=-(ti(5)+ti(6)/60)/60*2*pi+pi/2;
xm3=6.0*cos(tm);
ym3=6.0*sin(tm);
xm2=xm3/2+0.5*cos(tm-pi/2);
ym2=ym3/2+0.5*sin(tm-pi/2);
xm4=xm3/2-0.5*cos(tm-pi/2);
ym4=ym3/2-0.5*sin(tm-pi/2);
set(hm,'XData',[0 xm2 xm3 xm4 0],'YData',[0 ym2 ym3 ym4 0])
% 計(jì)算秒針位置
ts=-(ti(6))/60*2*pi+pi/2;
set(hs,'XData',[0 7*cos(ts)],'YData',[0 7*sin(ts)])
drawnow;
pause(0.09)
end
catch
end
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -