121794011
2009-03-20, 14:46
本人刚开始学习Matlab,感觉到他对数学很有用处,特别是矩阵,正在摸着石头过河学习,想编写这样一个界面
http://www.labfans.com/attachment.php?attachmentid=1777&stc=1&d=1237531540
就是有两个输入框让你输入X和Y的数值,点击下面的计算,就能算出来3x—4y的值,请求各位老师能解决
最好是能讲解一下,或者给个思路,小弟不胜感激
function test
OldHandle=findobj( 'Type', 'figure', 'Tag', 'test' );
if ishandle( OldHandle )
close( OldHandle );
end
fig=figure;
set(fig,'units','normalized','position',[0.2 0.2 0.6 0.7],...
'menubar','none','name','计算',...
'numbertitle','off','color',[79 129 188]/255,'tag','test');
backcolor=get(gcf,'Color');
uicontrol(gcf,'style','text','units','normalized','pos',[0.2 0.8 0.2 0.05],'string','请输入X的值',...
'fontsize',14,'fontweight','bold','fontunits','normalized','bac',backcolor)
uicontrol(gcf,'style','edit','units','normalized','pos',[0.2 0.7 0.2 0.08],...
'fontsize',14,'fontunits','normalized','string','','tag','edit1','backgroundcolor',[156 186 88]/255);
uicontrol(gcf,'style','text','units','normalized','pos',[0.6 0.8 0.2 0.05],'string','请输入Y的值',...
'fontsize',14,'fontweight','bold','fontunits','normalized','bac',backcolor)
uicontrol(gcf,'style','edit','units','normalized','pos',[0.6 0.7 0.2 0.08],...
'fontsize',14,'fontunits','normalized','string','','tag','edit2','backgroundcolor',[156 186 88]/255);
edit3=uicontrol(gcf,'style','edit','units','normalized','pos',[0.4 0.3 0.2 0.1],...
'fontsize',14,'fontunits','normalized','string','计算','tag','edit3',...
'backgroundcolor',[228 108 11]/255,'callback',...
['handles=guidata(gcf);'...
'x=str2num(get(handles.edit1,''string''));'...
'y=str2num(get(handles.edit2,''string''));'...
'set(handles.edit3,''string'',num2str(x+y));']);
set(edit3,'ButtonDownFcn',...
['handles=guidata(gcf);'...
'x=str2num(get(handles.edit1,''string''));'...
'y=str2num(get(handles.edit2,''string''));'...
'set(handles.edit3,''string'',num2str(x+y));'])
handles=guihandles(gcf);
guidata(gcf,handles);
vBulletin® v3.8.3,版权所有 ©2000-2025,Jelsoft Enterprises Ltd.