Меню

Error while evaluating uicontrol callback ошибка как решить

function varargout = CIEgui(varargin)

gui_Singleton = 1;

gui_State = struct(‘gui_Name’,mfilename,

‘gui_Singleton’, gui_Singleton,

‘gui_OpeningFcn’, @CIEgui_OpeningFcn,

‘gui_OutputFcn’, @CIEgui_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 % — Executes just before CIEgui is made visible. function CIEgui_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 CIEgui (see VARARGIN)

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

% Update handles structure guidata(hObject, handles);

% UIWAIT makes CIEgui wait for user response (see UIRESUME) % uiwait(handles.figure1); function varargout = CIEgui_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 BrowseFile. function BrowseFile_Callback(hObject, eventdata, handles) [FileName,PathName] = uigetfile(‘*.txt’,’Select the txt file’);

if PathName ~= 0 %if user not select cancel PathNameFileName = [PathName FileName]; set(handles.filepath, ‘string’,PathNameFileName); %PathName = get(handles.filepath, ‘string’); addpath(PathName); %add path to file search

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %reading the color matching functions data = csvread(‘ciexyz31_1.csv’); wavelength = data(:,1); redCMF = data(:,2); greenCMF = data(:,3); blueCMF = data(:,4); %plot(wavelength,redCMF);

% readint the PL data fid = fopen(FileName, ‘r’); %PLdata = fscanf(fid, ‘%g %g’, [2 inf]); % It has two rows now. hl = str2num(get(handles.headerline,’string’)); PLdata = textscan(fid,’%f %f’,’HeaderLines’,hl);

%PLdata = dlmread(FileName, », 40, 1) %matrix = dlmread(filename, delimiter, firstRow, firstColumn) fclose(fid)

% PLwavelength = PLdata(1,:); % PLIntensity = PLdata(2,:);

PLwavelength = PLdata{1,1}; PLIntensity = PLdata{1,2};

plot(handles.PLdataaxis,PLwavelength,PLIntensity);

% CIE coordinates calculation %PLIntensity = PLIntensity/max(PLIntensity); %normalize Intensity

s = size(PLwavelength); dataindex = 0; %index for ciexydata for i=1:1:471 % i is for color function read from excel file for j=1:1:s(1,1) if wavelength(i,1)== PLwavelength(j,1); dataindex = dataindex + 1; CIEXydata(dataindex,1) = redCMF(i,1)*PLIntensity(j,1); CIEYydata(dataindex,1) = greenCMF(i,1)*PLIntensity(j,1); CIEZydata(dataindex,1) = blueCMF(i,1)*PLIntensity(j,1); wave(dataindex,1) = PLwavelength(j,1); end end end set(handles.Calculatepushbutton,’Enable’,’on’); %enable the push button for calculate handles.X = trapz(wave,CIEXydata); handles.Y = trapz(wave,CIEYydata); handles.Z = trapz(wave,CIEZydata); guidata(hObject, handles); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % — Executes during object creation, after setting all properties. function PLdataaxis_CreateFcn(hObject, eventdata, handles) % hObject handle to CIEdiagram (see GCBO) % eventdata reserved — to be defined in a future version of MATLAB % handles empty — handles not created until after all CreateFcns called

% Hint: place code in OpeningFcn to populate CIEdiagram

function filepath_Callback(hObject, eventdata, handles)

% hObject handle to filepath (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 filepath as text % str2double(get(hObject,’String’)) returns contents of filepath as a double % — Executes during object creation, after setting all properties. function filepath_CreateFcn(hObject, eventdata, handles) %handles.filepath = hObject; %guidata(hObject, handles); % hObject handle to filepath (see GCBO) % eventdata reserved — to be defined in a future version of MATLAB % handles empty — handles not created until after all CreateFcns called if ispc && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’)) set(hObject,’BackgroundColor’,’white’); end

% — Executes on button press in Calculatepushbutton. function Calculatepushbutton_Callback(hObject, eventdata, handles) handles.smallx = handles.X / (handles.X + handles.Y + handles.Z); handles.smally = handles.Y / (handles.X + handles.Y + handles.Z); set(handles.CIEX,’string’,handles.X); set(handles.CIEY,’string’,handles.Y); set(handles.CIEZ,’string’,handles.Z); set(handles.CIEsmallx,’string’,handles.smallx); set(handles.CIEsmally,’string’,handles.smally);

%plotting the locatino in CIE diagram xx = handles.smallx; %modified x,y cordinate with respect to the top left axis origin yy = (0.9-handles.smally);

imsize = imread(‘CIExy1931.bmp’); simsize = size(imsize); xaxis = (simsize(1,2)/0.9)*xx+1; %getting axis cordinates yaxis = (simsize(1,1)/0.9)*yy+1; yaxis = round(yaxis); xaxis = round(xaxis); %calibration — the image is little shifted so calibrated by calulating CIE %for 0.33,0.33 and matching that to white poinit pixel in the image used %(700,385) xaxis = xaxis + 22; yaxis = yaxis + 5; axes(handles.CIEdiagram);

hold on;%# Add subsequent plots to the image cla imshow(‘CIExy1931.bmp’); plot(xaxis,yaxis,’o’); %# NOTE: x_p and y_p are switched (see note below hold off; %# Any subsequent plotting will overwrite the image %declare handles to be used in save window handles.savexaxis = xaxis; handles.saveyaxis = yaxis; guidata(hObject, handles); %[filename, user_canceled] = imsave; % axes.save(‘test.jpg’); %getting the RGB value ximaxis = simsize(1,1) + (-simsize(1,1)/0.9)*handles.smally; yimaxis = (simsize(1,2)/0.9)*handles.smallx; ximaxis = round(ximaxis); yimaxis = round(yimaxis); %calibration — the image is little shifted so calibrated by calulating CIE %for 0.33,0.33 and matching that to white poinit pixel in the image used %(700,385) ximaxis = ximaxis + 5; yimaxis = yimaxis + 22; image = imread(‘CIExy1931.bmp’); imager = image(ximaxis,yimaxis,1); imageg = image(ximaxis,yimaxis,2); imageb = image(ximaxis,yimaxis,3);

colorwind = imread(‘colorwindow.png’); %setting rgb for color window colorwind(:,:,1) = imager; colorwind(:,:,2) = imageg; colorwind(:,:,3) = imageb;

axes(handles.colorwindowaxes); imshow(colorwind); set(handles.Calculatepushbutton,’Enable’,’off’); %disable the push button for calculate set(handles.savepushbutton,’Enable’,’on’);

% — Executes during object creation, after setting all properties. function CIEdiagram_CreateFcn(hObject, eventdata, handles) handles.CIEdiagram = hObject; guidata(hObject, handles); imshow(‘CIExy1931.bmp’); %imshow(‘findpointer1.png’); % hold on; %# Add subsequent plots to the image % plot(1,460,’o’); %# NOTE: x_p and y_p are switched (see note below)! % hold off; %# Any subsequent plotting will overwrite the image! % hObject handle to CIEdiagram (see GCBO) % eventdata reserved — to be defined in a future version of MATLAB % handles empty — handles not created until after all CreateFcns called

% Hint: place code in OpeningFcn to populate CIEdiagram

% — Executes during object creation, after setting all properties. function colorwindowaxes_CreateFcn(hObject, eventdata, handles) handles.colorwindowaxes = hObject; guidata(hObject, handles); imshow(‘colorwindow.png’) % hObject handle to CIEdiagram (see GCBO) % eventdata reserved — to be defined in a future version of MATLAB % handles empty — handles not created until after all CreateFcns called

% Hint: place code in OpeningFcn to populate CIEdiagram

% — Executes during object creation, after setting all properties. function Calculatepushbutton_CreateFcn(hObject, eventdata, handles) handles.Calculatepushbutton = hObject; % Update handles structure guidata(hObject, handles); set(hObject,’Enable’,’off’); %disable the push button for calculate

% — Executes on button press in saveimage. function saveimage_Callback(hObject, eventdata, handles) %[filename, ext, user_canceled] = imputfile axes(handles.CIEdiagram); save(test.jpg); %[filename, user_canceled] = imsave; if user_canceled == 0

function headerline_Callback(hObject, eventdata, handles) %handles.headerline = hObject; %guidata(hObject, handles); % hObject handle to headerline (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 headerline as text % str2double(get(hObject,’String’)) returns contents of headerline as a double

% — Executes during object creation, after setting all properties. function headerline_CreateFcn(hObject, eventdata, handles) handles.headerline = hObject; guidata(hObject, handles);

% hObject handle to headerline (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 savepushbutton. function savepushbutton_Callback(hObject, eventdata, handles) figure(‘Name’,’Save Image’,’NumberTitle’,’off’) image = imread(‘CIExy1931.bmp’); imshow(image); hold on plot(handles.savexaxis,handles.saveyaxis,’o’); %# NOTE: x_p and y_p are switched (see note below hold off; %# Any subsequent plotting will overwrite the image % hObject handle to savepushbutton (see GCBO) % eventdata reserved — to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

% — Executes during object creation, after setting all properties. function savepushbutton_CreateFcn(hObject, eventdata, handles) handles.savepushbutton = hObject; guidata(hObject, handles); set(handles.savepushbutton,’Enable’,’off’); % hObject handle to savepushbutton (see GCBO) % eventdata reserved — to be defined in a future version of MATLAB % handles empty — handles not created until after all CreateFcns called ——— This is full code, can you help me with my problem. I have 2 data (file attached), data1 is good but data2 have some errors. I dont know why? Help me! Thanks a lot.

function slider1
global hSt1 hEd2 hSld1 hSld2
hFig=figure(‘position’,[50,50,400,300]);
hSt1=uicontrol(‘Style’,’text’,’Position’,[130,25,40,20],…
‘Backgroundcolor’,[1 1 1],’String’,’0′);
hSld1=uicontrol (‘Style’,’slider’,’Position’,[50,50,200,20],…
‘Callback’,’sld’);
uicontrol(‘Style’,’text’,’Position’,[50,25,80,20],…
‘String’,’Окно вывода’);
hEd2=uicontrol(‘Style’,’edit’,’Position’,[260,255,40,20],…
‘Backgroundcolor’,[1 1 1],’String’,’0′,…
‘Callback’,’fed’);
uicontrol(‘Style’,’text’,’Position’,[180,255,80,20],…
‘String’,’Окно ввода’);
hSld1=uicontrol (‘Style’,’slider’,’Position’,[270,50,20,200]);

function sld
global hSt1 hSld1
set(hSt1,’String’,num2str(get(hsld,’Value’)));
end

function fed
global hEd2 hSld2
set(hSld2,’Value’,str2num(get(hed2,’String’)));
end



по идеи должно про скроле менятся значение но этого не происходит. ошибку пишет!!!

??? Error while evaluating uicontrol Callback.

??? Undefined function or variable ‘sld’.

??? Error while evaluating uicontrol Callback.

??? Undefined function or variable ‘sld’.

??? Error while evaluating uicontrol Callback.

??? Undefined function or variable ‘sld’.

??? Error while evaluating uicontrol Callback.

??? Undefined function or variable ‘fed’.

??? Error while evaluating uicontrol Callback.

davit petraasya

My code is running on Matlab 7.10.0(R2010a),if I want to run the code on Matlab 2016a giving error:

Error in seasonal_trend/construct_GUI/select_file (line 892)

set_busy();

Error while evaluating UIControl Callback

I attached my code, excel file and screen video how to run the code. I would be very greatful, if someone can help me to solvethe issue.


Answers (0)

See Also

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.

davit petraasya

My code is running on Matlab 7.10.0(R2010a),if I want to run the code on Matlab 2016a giving error:

Error in seasonal_trend/construct_GUI/select_file (line 892)

set_busy();

Error while evaluating UIControl Callback

I attached my code, excel file and screen video how to run the code. I would be very greatful, if someone can help me to solvethe issue.


Answers (0)

See Also

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.

If I go back to the GUI and perform GUI operations, an error rises if I push a button.

Whenever I try to go back to the GUI, after performing script operations on the dataset, I can’t push buttons in dialogue boxes, as the following error shows up:

Unable to use a value of type ‘matlab.ui.control.UIControl’ as an index.

Error using inputgui (line 218)
Error while evaluating UIControl Callback.

#### Example (I’ll shorthand something to make it lighter)

  1. [ALLEEG, EEG, CURRENTSET, ALLCOM] = eeglab;
    EEG = pop_loadbv(rootfold, sprintf(‘MMM_000%i.vhdr’,set));
    pop_newset(ALLEEG, EEG, 0,’setname’, sprintf(‘s0%i_raw’,set), ‘gui’,’off’);
    EEG = pop_resample( EEG, 250);
    EEG = pop_chanedit(EEG, ‘lookup’,’filelocation’);
    [ALLEEG, EEG, CURRENTSET] = pop_newset(ALLEEG, EEG, 1,’setname’,sprintf(‘s0%i_1hpf’,set),’gui’,’off’); % ICA dataset
    EEG = pop_eegfiltnew(EEG, ‘locutoff’,1);
    EEG = pop_cleanline(EEG, … % parameters)
    oriEEG = EEG;
    EEG = clean_rawdata(EEG, 5, -1, 0.80, ‘off’, 8, 0.25);
    EEG = pop_interp(EEG, oriEEG.chanlocs, ‘spherical’);
    EEG = pop_reref( EEG, [29 30] ,’keepref’,’on’);
    EEG = pop_eegchanoperator( EEG, {‘ch65=ch31-ch32 label biVEOG’}); %bipolar ocular channels
    EEG = pop_eegchanoperator( EEG, {‘ch66=ch57-ch58 label biHEOG’});
    command = ‘[EEG LASTCOM] = eeg_eegrej(EEG,eegplot2event(TMPREJ, -1));’;
    eegplot(EEG.data, ‘srate’, EEG.srate, ‘events’, EEG.event, ‘command’, command, ‘winlength’, 100);
  2. [As the software plots the EEG data scroll, I can’t push the Norm and Stack buttons on the right, as the error above appears.]
  3. [The same happens if I run > pop_runamica(EEG), where I can’t press the button to run the algorithm.]

#### Versions

OS version [Windows 10]
Matlab version [Matlab 2019a]
EEGLAB version [eeglab2019_0]

Содержание

  1. Error while evaluating UIControl Callback.
  2. Direct link to this question
  3. Direct link to this question
  4. Direct link to this comment
  5. Direct link to this comment
  6. Answers (0)
  7. See Also
  8. Categories
  9. Products
  10. Release
  11. Community Treasure Hunt
  12. How to Get Best Site Performance
  13. Americas
  14. Europe
  15. Asia Pacific
  16. Error while evaluating uicontrol Callback
  17. Direct link to this question
  18. Direct link to this question
  19. Accepted Answer
  20. Direct link to this answer
  21. Direct link to this answer
  22. Direct link to this comment
  23. Direct link to this comment
  24. More Answers (0)
  25. See Also
  26. Categories
  27. Community Treasure Hunt
  28. How to Get Best Site Performance
  29. Americas
  30. Europe
  31. Asia Pacific
  32. Error while evaluating uicontrol Callback
  33. Direct link to this question
  34. Direct link to this question
  35. Direct link to this comment
  36. Direct link to this comment
  37. Answers (1)
  38. Direct link to this answer
  39. Direct link to this answer
  40. Direct link to this comment
  41. Direct link to this comment
  42. See Also
  43. Categories
  44. Community Treasure Hunt
  45. How to Get Best Site Performance
  46. Americas
  47. Europe
  48. Asia Pacific
  49. «Error While Evaluating UIControl Callback»
  50. Direct link to this question
  51. Direct link to this question
  52. Direct link to this comment
  53. Direct link to this comment
  54. Answers (1)
  55. Direct link to this answer
  56. Direct link to this answer
  57. See Also
  58. Categories
  59. Community Treasure Hunt
  60. How to Get Best Site Performance
  61. Americas
  62. Europe
  63. Asia Pacific
  64. Error while evaluating uicontrol Callback
  65. Direct link to this question
  66. Direct link to this question
  67. Direct link to this comment
  68. Direct link to this comment
  69. Answers (1)
  70. Direct link to this answer
  71. Direct link to this answer
  72. Direct link to this comment
  73. Direct link to this comment
  74. See Also
  75. Categories
  76. Community Treasure Hunt
  77. How to Get Best Site Performance
  78. Americas
  79. Europe
  80. Asia Pacific

Error while evaluating UIControl Callback.

Direct link to this question

Direct link to this question

1 Comment

Direct link to this comment

Direct link to this comment

Answers (0)

See Also

Categories

Products

Release

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.

Select a Web Site

READ  Ufs прошивки для телефонов

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

Americas

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
    • 简体中文 Chinese
    • English
  • 日本 Japanese (日本語)
  • 한국 Korean (한국어)

Accelerating the pace of engineering and science

MathWorks is the leading developer of mathematical computing software for engineers and scientists.

Источник

Error while evaluating uicontrol Callback

Direct link to this question

Direct link to this question

0 Comments

Accepted Answer

Direct link to this answer

Direct link to this answer

1 Comment

Direct link to this comment

Direct link to this comment

More Answers (0)

See Also

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

Americas

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
    • 简体中文 Chinese
    • English
  • 日本 Japanese (日本語)
  • 한국 Korean (한국어)

Accelerating the pace of engineering and science

READ  There is an error in xml document ошибка

MathWorks is the leading developer of mathematical computing software for engineers and scientists.

Источник

Error while evaluating uicontrol Callback

Direct link to this question

Direct link to this question

1 Comment

Direct link to this comment

Direct link to this comment

Answers (1)

Direct link to this answer

Direct link to this answer

1 Comment

Direct link to this comment

Direct link to this comment

See Also

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

Americas

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
    • 简体中文 Chinese
    • English
  • 日本 Japanese (日本語)
  • 한국 Korean (한국어)

Accelerating the pace of engineering and science

MathWorks is the leading developer of mathematical computing software for engineers and scientists.

Источник

«Error While Evaluating UIControl Callback»

Direct link to this question

Direct link to this question

1 Comment

Direct link to this comment

Direct link to this comment

Answers (1)

Direct link to this answer

Direct link to this answer

0 Comments

See Also

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

READ  Wanqi allwinner t3 p1 прошивка

You can also select a web site from the following list:

How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

Americas

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
    • 简体中文 Chinese
    • English
  • 日本 Japanese (日本語)
  • 한국 Korean (한국어)

Accelerating the pace of engineering and science

MathWorks is the leading developer of mathematical computing software for engineers and scientists.

Источник

Error while evaluating uicontrol Callback

Direct link to this question

Direct link to this question

1 Comment

Direct link to this comment

Direct link to this comment

Answers (1)

Direct link to this answer

Direct link to this answer

1 Comment

Direct link to this comment

Direct link to this comment

See Also

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

Americas

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
    • 简体中文 Chinese
    • English
  • 日本 Japanese (日本語)
  • 한국 Korean (한국어)

Accelerating the pace of engineering and science

MathWorks is the leading developer of mathematical computing software for engineers and scientists.

Источник

Вопрос:

У меня есть GUI Matlab (Compare2ImagesGUI), который вызывается в другом GUI (DistanceOrderGUI) и должен возвращать переменную, основанную на некотором взаимодействии с пользователем.

Ниже приведен фрагмент того, как Compare2ImagesGUI:

a=1;b=2;
handles.a = a;
handles.b = b;

result = Compare2ImagesGUI('DistanceOrderGUI', handles)

И вот что он делает, когда он открывается:

function Compare2ImagesGUI_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 Compare2ImagesGUI (see VARARGIN)

% Choose default command line output for Compare2ImagesGUI
%handles.output = hObject;
a = varargin{2}.a;
b = varargin{2}.b;
handles.a = a;
handles.b = b;
handles.ima = varargin{2}.ims{a};
handles.imb = varargin{2}.ims{b};
init(hObject,handles);

% UIWAIT makes Compare2ImagesGUI wait for user response (see UIRESUME)
uiwait(hObject);

это функция init:

function init(hObject,handles)

imshow(handles.ima,'Parent',handles.axes1);
handles.current = handles.a;

% handles.ims=ims; handles.gt=gt;
% handles.folderN=folderN; handles.name=dirnames{folderN};

% Update handles structure
guidata(hObject, handles);

Когда пользователь заканчивает взаимодействие, он нажимает кнопку, и GUI должен закрываться и возвращать значение своей вызывающей функции:

% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
figure1_CloseRequestFcn(hObject,handles);

% --- Outputs from this function are returned to the command line.
function varargout = Compare2ImagesGUI_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.current

delete(handles.Compare2ImagesGUI);


% --- Executes when user attempts to close figure1.
function figure1_CloseRequestFcn(hObject, handles)
% hObject    handle to figure1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

if isequal(get(hObject,'waitstatus'),'waiting')
uiresume(hObject);
else
delete(hObject);
end

Я следовал инструкции о том, как структурировать этот код, найденный здесь и здесь, тем не менее я получаю эту странную ошибку и действительно не знаю, что с этим делать:

Error using hg.uicontrol/get
The name 'waitstatus' is not an accessible property for an instance of
class 'uicontrol'.

Error in Compare2ImagesGUI>figure1_CloseRequestFcn (line 127)
if isequal(get(hObject,'waitstatus'),'waiting')

Error in Compare2ImagesGUI>pushbutton3_Callback (line 118)
figure1_CloseRequestFcn(hObject,handles);

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

Error in Compare2ImagesGUI (line 42)
gui_mainfcn(gui_State, varargin{:});

Error in
@(hObject,eventdata)Compare2ImagesGUI('pushbutton3_Callback',hObject,eventdata,guidata(hObject))


Error using waitfor
Error while evaluating uicontrol Callback

Обратите внимание, что строка 127 находится в function figure1_CloseRequestFcn(hObject, handles). Какие-либо предложения?

Ответ №1

Обычно CloseRequestFcn не вызывается через uicontrol который вы создали, а скорее:

  • вы закрываете фигуру с помощью встроенных элементов управления фигурами (например, “X” в верхней части экрана или в меню рисунков)
  • close для вашей фигуры
  • покинуть MATLAB

Случается, что pushbutton3_Callback передает свой собственный дескриптор, а фигурный дескриптор в hObject в figure1_CloseRequestFcn. Проблема в том, что свойство 'waitstatus' принадлежит только figure.

Решение состоит в том, чтобы либо изменить pushbutton3_Callback чтобы передать фигуру, либо изменить pushbutton3_Callback чтобы просто использовать фигурный дескриптор. Например:

% --- Executes when user attempts to close figure1.
function figure1_CloseRequestFcn(hObject, eventdata, handles)
% hObject    handle to figure1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

hFig = ancestor(hObject,'Figure');
if isequal(get(hFig,'waitstatus'),'waiting')
uiresume(hFig);
else
delete(hFig);
end

Примечание: Я добавил и eventdata аргумент figure1_CloseRequestFcn, который, казалось, не хватает из вашего кода. (Обычно он определяется как @(hObject,eventdata)guitest('figure1_CloseRequestFcn',hObject,eventdata,guidata(hObject))).

I created pushbutton in GUI;

% — 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)

[FileName1,PathName] = uigetfile(‘*.xlsx’,‘Select the excel file’);

[num,txt1,raw] = xlsread(FileName1);

%when user click pushbutton then click close the «select the excel file» window following errors occur;

Error using xlsread

Filename must be a string.

Error in helmert_fig>pushbutton1_Callback (line 84)

[num,txt1,raw] = xlsread(FileName1);

Error in gui_mainfcn (line 96)

feval(varargin{:});

Error in helmert_fig (line 42)

gui_mainfcn(gui_State, varargin{:});

Error in @(hObject,eventdata)helmert_fig(‘pushbutton1_Callback’,hObject,eventdata,guidata(hObject))

Error while evaluating uicontrol Callback

%how I can modify the xlsread function to supress these errors when user close the window without select any file to read?

0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии

А вот еще интересные материалы:

  • Яшка сломя голову остановился исправьте ошибки
  • Ясность цели позволяет целеустремленно добиваться намеченного исправьте ошибки
  • Ясность цели позволяет целеустремленно добиваться намеченного где ошибка
  • Error stray 342 in program ошибка
  • Error status ext ram exception 0xc0050005 ошибка flashtool как исправить