MatlabGUI,使用静态文本框的输入,并使用基本按钮进行转换

MatlabGUI,使用静态文本框的输入,并使用基本按钮进行转换,matlab,user-interface,Matlab,User Interface,我正在努力研究MatlabGUI界面的工作原理 我不是在寻找答案,只是想得到更多关于如何做到这一点的指导 我试图将编辑框中的温度从F转换为C…所以我想我需要在按钮中输入公式 我想我被困在如何将数字从编辑框传递到按钮以转换它,然后如何将其传递回,然后显示它。 这有什么意义吗 function varargout = ICA09A_TEMPFtoC(varargin) % ICA09A_TEMPFTOC MATLAB code for ICA09A_TEMPFtoC.fig % ICA09

我正在努力研究MatlabGUI界面的工作原理

我不是在寻找答案,只是想得到更多关于如何做到这一点的指导

我试图将编辑框中的温度从F转换为C…所以我想我需要在按钮中输入公式

我想我被困在如何将数字从编辑框传递到按钮以转换它,然后如何将其传递回,然后显示它。 这有什么意义吗

function varargout = ICA09A_TEMPFtoC(varargin)
% ICA09A_TEMPFTOC MATLAB code for ICA09A_TEMPFtoC.fig
%      ICA09A_TEMPFTOC, by itself, creates a new ICA09A_TEMPFTOC or raises the existing
%      singleton*.
%
%      H = ICA09A_TEMPFTOC returns the handle to a new ICA09A_TEMPFTOC or the handle to
%      the existing singleton*.
%
%      ICA09A_TEMPFTOC('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in ICA09A_TEMPFTOC.M with the given input arguments.
%
%      ICA09A_TEMPFTOC('Property','Value',...) creates a new ICA09A_TEMPFTOC or raises     the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before ICA09A_TEMPFtoC_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to ICA09A_TEMPFtoC_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 ICA09A_TEMPFtoC

% Last Modified by GUIDE v2.5 20-Mar-2013 13:14:08

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @ICA09A_TEMPFtoC_OpeningFcn, ...
                   'gui_OutputFcn',  @ICA09A_TEMPFtoC_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(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 ICA09A_TEMPFtoC is made visible.
function ICA09A_TEMPFtoC_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 ICA09A_TEMPFtoC (see VARARGIN)

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

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes ICA09A_TEMPFtoC wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = ICA09A_TEMPFtoC_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 on button press in convert_pb.
function convert_pb_Callback(hObject, eventdata, handles)
% hObject    handle to convert_pb (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
InputString = get(handles.convert_pb,'Convert');

InputNumber = str2num(InputString);

Result = (5 / 9) * (InputNumber - 32);

set(handles.result, 'Convert', Result);


function degF_et_Callback(hObject, eventdata, handles)
% hObject    handle to degF_et (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 degF_et as text
%        str2double(get(hObject,'String')) returns contents of degF_et as a double
UserInput = str2double(get(hObject,'String'))

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

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
    if ispc && isequal(get(hObject,'BackgroundColor'),          get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

我应该做些什么来让编辑人员更易于阅读?

要在文本编辑框中输入温度,请使用:

tempF = get(handles.degF_et,'String');
这可以通过按钮功能调用

要更改此处显示的字符串,请使用:

set(handles.degF_et,'String','some string');

你能发布你到目前为止的代码吗?给我一分钟…处理它。对于任何混乱的行,我很抱歉,我总是很难添加代码到这个网站。