声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 2099|回复: 5

[GUI界面] GUI结果输出求助

[复制链接]
发表于 2006-12-6 16:44 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
小弟最近在编写一个GUI计算界面,在界面中输入参数后想把计算结果输出到界面上来
哪位老兄知道怎么操作,能否指教小弟一二,不胜感激。谢谢大家!!
回复
分享到:

使用道具 举报

发表于 2006-12-6 17:05 | 显示全部楼层
比如说放一个Label,把结果放到Label的String属性里就可以了
不知道你的计算结果是什么样的
发表于 2006-12-7 19:38 | 显示全部楼层
他时说的callback函数的写法,这个其实我也不会,大体要先有一个load的Button,把你输入的文件接收过来,然后再显办法显示出来,我一直学不会gui,这方面教材也少,书中一般到这一部分都是最后一章,寥寥几页就完了。这是matlab提示的程序框架。
%我把figue名改为my001了
function varargout = my001(varargin)
% MY001 M-file for my001.fig
%      MY001, by itself, creates a new MY001 or raises the existing
%      singleton*.
%
%      H = MY001 returns the handle to a new MY001 or the handle to
%      the existing singleton*.
%
%      MY001('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in MY001.M with the given input arguments.
%
%      MY001('Property','Value',...) creates a new MY001 or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before my001_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to my001_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help my001

% Last Modified by GUIDE v2.5 07-Dec-2006 19:05:04

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @my001_OpeningFcn, ...
                   'gui_OutputFcn',  @my001_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin & isstr(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before my001 is made visible.
function my001_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to my001 (see VARARGIN)

% Choose default command line output for my001
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes my001 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = my001_OutputFcn(hObject, eventdata, handles)
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;


% --- Executes during object creation, after setting all properties.
function slider1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background, change
%       'usewhitebg' to 0 to use default.  See ISPC and COMPUTER.
usewhitebg = 1;
if usewhitebg
    set(hObject,'BackgroundColor',[.9 .9 .9]);
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


% --- Executes on slider movement.
function slider1_Callback(hObject, eventdata, handles)
% hObject    handle to slider1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider



function Edit_Text_Callback(hObject, eventdata, handles)
% hObject    handle to Edit_Text (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of Edit_Text as text
%        str2double(get(hObject,'String')) returns contents of Edit_Text as a double

我想设计一个界面,能显示一个波形,有一个edit_text可以改变一下参数,比如频率f等。一直不会。grid on,grid off,close这几个不用编,其他的都不会了。前面板上设置了load,grid on,grid off,close,start这几个Button,一个slider还有一个Edit_text,matlab让我自己编slider还有Edit_text的callback,还有一个Axes的图形输出我不知道怎莫编的,主要是对finobj,guidata,gcbo等这些函数弄不太明白,其实我一直都没弄清handle到底是使什莫,感觉是一个面向对象的类名,因为它引出的都是property,二比她高一级的事figure,我的认识figure和property可以直接建立联系,一直没弄明白handle到底是什莫,还希望路过的大牛指点!
 楼主| 发表于 2006-12-9 21:11 | 显示全部楼层
我算的是一个系统扭振的前8阶固有频率,想一次性把几个频率值都输出在界面上,衷心感谢mulan兄和vib兄的热心回复。
发表于 2006-12-11 10:40 | 显示全部楼层
原帖由 hxg2001619 于 2006-12-6 16:44 发表
小弟最近在编写一个GUI计算界面,在界面中输入参数后想把计算结果输出到界面上来
哪位老兄知道怎么操作,能否指教小弟一二,不胜感激。谢谢大家!!


我不懂你那个专业知识 .
  比如有三个edit
   
       a= str2num(get(handles.edit1,'string'))
       b=str2num(get(handles.edit2,'string'))

       c=set(handles.edit3,'string','moshu')
不知道我说的对不对
 楼主| 发表于 2006-12-14 19:13 | 显示全部楼层
问题已经解决
谢谢楼上的 mulan,vib,tirfan三位老兄的提点!!
在这里向大家表示感谢
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-11-25 01:43 , Processed in 0.055109 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表