MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB论坛 (https://www.labfans.com/bbs/forumdisplay.php?f=6)
-   -   [求助]如何制作这样的矩阵运算的matlab gui简单界面 (https://www.labfans.com/bbs/showthread.php?t=6959)

121794011 2009-03-20 14:46

[求助]如何制作这样的矩阵运算的matlab gui简单界面
 
2 个附件
本人刚开始学习Matlab,感觉到他对数学很有用处,特别是矩阵,正在摸着石头过河学习,想编写这样一个界面
[IMG]http://www.labfans.com/attachment.php?attachmentid=1777&stc=1&d=1237531540[/IMG]

就是有两个输入框让你输入X和Y的数值,点击下面的计算,就能算出来3x—4y的值,请求各位老师能解决
最好是能讲解一下,或者给个思路,小弟不胜感激

xiezhh 2009-03-21 10:20

回复: [求助]如何制作这样的矩阵运算的matlab gui简单界面
 
2 个附件
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);

121794011 2009-03-21 14:59

回复: [求助]如何制作这样的矩阵运算的matlab gui简单界面
 
谢谢你的回复,真的很感谢你


所有时间均为北京时间。现在的时间是 11:12

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.