在Matlab中在GUI之间传递变量

时间:2013-04-05 04:41:27

标签: matlab variables user-interface

我是matlab的新手,并且没有多长时间来制作互连的GUI。从具体的例子开始工作要容易得多。我找到了通用示例,但不知道哪些部分是Matlab函数,哪些部分需要编辑。是否有可能为此代码演示如何将edittext中的信息传递到bladedesign.fig以及如何在bladedesign.fig中访问它们?

Pushbutton4是一个提交按钮。 edittext9是一个可变文本框。

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


% --- Executes during object creation, after setting all properties.
function edit9_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit9 (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

% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
close(gcf)
openfig(bladedesign.fig)

1 个答案:

答案 0 :(得分:0)

不确定我理解你的问题。

无花果不“做”任何东西,它就在那里, .m文件可以更新图,而图将立即反映变化

你提供的%暗示很多。

hObject是调用该调用的对象,尝试在回调中插入一个断点(F12)并检查你在那里有什么

如果你想访问其他数据,“handles”变量全部拥有它们(虽然只在不在CreateFcn上的回调上)

so handles.pushbutton4 和handles.edit9

是你正在寻找的wones