2013-04-05 72 views
-1

我是matlab新手,並沒有太長的時間來生成相互連接的GUI。從特定的例子開始工作要容易得多。我已經找到了通用的例子,但不知道哪些部分是Matlab函數,哪些需要編輯。是否有可能證明此代碼如何將來自edittext的信息傳遞到bladedesign.fig以及如何在bladedesign.fig中訪問它們?在Matlab中的GUI之間傳遞變量

按鈕4是一個提交按鈕。 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) 

回答

0

不知道我明白你的問題。

無花果不「做」 anyhthing,它只是存在, .m文件可以更新無花果,無花果會立即反映更改

的提示%你必須有相當多它。

的hObject,是調用調用的對象,請嘗試將回調一個破發點(F12),並檢查是否有什麼在那裏

的情況下,你要訪問其他數據的「把手」變量都有他們都(雖然只在回調不CreateFcn)

所以handles.pushbutton4 和handles.edit9

是你正在尋找的wones

+0

對不起我的意思designblade.m 所以在designblade.m我可以訪問menu.m中的句柄? 我只需要在designblade.m中以相同的方式調用數據,因爲我必須稍後在menu.m中進行計算。 – Marc 2013-04-06 20:01:25