📄 shootinggui.m
字号:
% 关于线性打靶法的GUI文件,函数方程用shootingfun.m文件
close all
figure;
axes('position',[0.06,0.16,0.7,0.6]);
p='y''(0)=';P='\Delta(y(1))';Q=[];
Sl=uicontrol(gcf,'style','slider',...
'unit','normalized','position',[0.93,0.02,0.03,0.9],...
'BackgroundColor',[0.9 0.9 0.9],'ForegroundColor','r',...
'fontsize',14,'SliderStep',[0.01,0.01]);
set(Sl,'callback',['a=str2num(get(Ed1,''string''));',...
'b=str2num(get(Ed0,''string''));',...
'y0=b+(a-b)*get(Sl,''value'');q=num2str(y0);',...
'set(Te,''string'',[p,q]);eval(SS);']);
Te=uicontrol(gcf,'style','text',...
'unit','normalized','position',[0.78,0.92,0.24,0.05],...
'BackgroundColor','w','ForegroundColor','r',...
'fontsize',10,'string',['y''(0)=',...
num2str(get(Sl,'value'))]);Ed1=uicontrol(gcf,'style','edit',...
'unit','normalized','position',[0.81,0.86,0.1,0.05],...
'BackgroundColor','w','ForegroundColor','r',...
'string','2');
Ed0=uicontrol(gcf,'style','edit',...
'unit','normalized','position',[0.81,0.02,0.1,0.05],...
'BackgroundColor','w','ForegroundColor','r',...
'string','0');
Te0=uicontrol(gcf,'style','text',...
'unit','normalized','position',[0.11,0.8,0.4,0.2],...
'BackgroundColor',[0.8 0.8 0.9],'ForegroundColor','b',...
'string',{'differential equations:',...
'y''''+ty''-4y=12t^2-3t 0<t<1','y(0)=0,y(1)=2'},...
'fontsize',14,'HorizontalAlignment','left');
plot([0,1],[0,2],'r*');hold on;plot([0,1],[0,2],'rs');
SS=['[t,y]=ode45(@shootingfun,[0,1],[0,y0]);',...
'set(h,''xdata'',t);set(h,''ydata'',y(:,1));',...
'set(DD,''string'',{P,num2str(y(end,1)-2)});'];
h=plot([0,1],[0,0]);
DD=uicontrol(gcf,'style','text',...
'unit','normalized','position',[0.55,0.8,0.18,0.14],...
'BackgroundColor','w','ForegroundColor','r',...
'string',{P,Q});
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -