GUI matlab中的UIControl回调

时间:2015-01-23 12:27:38

标签: matlab user-interface matlab-guide

我有一个以下的GUI程序来运行matlab 2014b中的另一个gui图。

% --- Executes on button press in Spectrometer
function Spectrometer_Callback(hObject, eventdata, handles)
% hObject    handle to Spectrometer (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
data = getappdata(gcbf, 'labdata');
% open Spectrometer only if it is not already open
if ~isfield(data,'hSpectrometer')
    data.hSpectrometer=SpectrometerGui('handle',num2str(gcbf,16));
elseif ~ishandle(str2double(data.hSpectrometer)) 
data.hSpectrometer=SpectrometerGui('handle',num2str(gcbf,16));
end
setappdata(gcbf, 'labdata', data); 

每次都会出现以下错误。不知道出错的原因是什么?

 Undefined function 'real' for input arguments of type 'matlab.ui.Figure'.

 Error in num2str (line 132)
        raw = cellPrintf(f, real(x), false);

Error in horus>Spectrometer_Callback (line 997)
    data.hSpectrometer=SpectrometerGui('handle',num2str(gcbf,16));

Error in gui_mainfcn (line 95)
        feval(varargin{:});

Error in lab (line 46)
    gui_mainfcn(gui_State, varargin{:});

Error in   @(hObject,eventdata)lab('Spectrometer_Callback',hObject,eventdata,guidata(hObject))  



Error while evaluating UIControl Callback

0 个答案:

没有答案