MATLAB:将GUI参数传递给脚本

时间:2016-08-01 15:59:21

标签: matlab

我正在运行一个来自gui的脚本,我想输入一些名为L_Al和L_InAs的参数的值,并将它们传递给脚本。以下是我的GUI.m文件的片段,我按下按钮运行脚本SchrodingerPoisson42,并尝试为参数L_Al和L_InAs分配值(参见最后几行):

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


    % --- Executes during object creation, after setting all properties.
   function L_InAs_CreateFcn(hObject, eventdata, handles)
    % hObject    handle to L_InAs (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 pushbutton1.
    function pushbutton1_Callback(hObject, eventdata, handles)
    % hObject    handle to pushbutton1 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    L_Al = str2num(get(handles.L_Al,'String'));
    L_InAs = str2num(get(handles.L_InAs,'String'));
    schrodingerpoisson42;

0 个答案:

没有答案