Matlab error while evaluating uicontrol callback

Hi everybody. My problem is about programmed GUI when I press the push button on the calculator. function BrowseFile_Callback(hObject, eventdata, handles) [FileName,PathName] = uigetfile(...

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.

Содержание

  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

Читайте также:  Nikon coolpix 5200 прошивка

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

Читайте также:  Error expected unqualified id before int

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: .

Читайте также:  Git upload pack git pack objects died with error

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.

Источник

Исходная проблема состояла в следующем:
1. есть графическое окно
figure(‘MenuBar’,’None’,’Name’,’Rout’, ‘NumberTitle’,’Off’);
для ввода числа, используемого в расчетах, задано окно
uicontrol(‘Style’,’edit’, ‘String’,’ ‘, ‘Position’,[40,340,60,25],’Tag’,’edt_s’);
при попытке переход от оконного представления к количественному с помощью
s=str2num(get(handles.edt_s,’String’));
выдается ошибка

Undefined variable «handles» or function «handles.edt_s»
Error in ChageRout_2_hand (line 11)
s=str2num(get(handles.edt_s,’String’))

2. Если использовать кнопку, при нажатии которой должен начинаться расчет
uicontrol(‘Style’,’PushButton’, ‘String’,’calc’, ‘Position’,[40,210,35,25], ‘Tag’,’push_calc’)
и применить функцию Callback
function push_calc_Callback(hObject, eventdata, handles)
s=str2num(get(handles.edt_s,’String’));

выдается сообщение об ошибке

Function definitions are not permitted in this context

Разъясните, пожалуйста, вопросы по скрипту-ответу от letete
1. Фрагмент скрипта-ответа

Matlab M

hFig = figure('MenuBar','None','Name','Rout', 'NumberTitle','Off');
edt_s = uicontrol('Style','edit', 'String',' ', 'Position',[40,340,60,25],'Tag','edt_s');
% тогда по ЭТОМУ хэндлу к нему и обращаться:
s=str2num(get(edt_s, 'String')); 
% далее создаем кнопку:
push_calc = uicontrol('Style','PushButton', 'String','calc', 'Position',[40,210,35,25], 'Tag','push_calc')
% и вручную прикручиваем событие Callback:
set(push_calc, 'Callback', @push_calc_Callback)

дает ошибку:

Undefined function ‘push_calc_Callback’ for input arguments of type ‘double’.
Error while evaluating uicontrol Callback

2. Верно ли будет если перед началом скрипта поставить «function» и после функции приведенной ниже также поставить end (чтобы «изначально делать файл-функцию и тогда колбэк будет вложенной функцией») и потом описываем соответствующую функцию:

Matlab M
1
2
3
function push_calc_Callback(hObject, eventdata, handles)
    s = str2num(get(hObject,'String')); 
end



0



Ntasha

Newbie
Posts: 5
Joined: Wed Oct 25, 2017 8:57 am

UIControl Callback

I keep on getting UIControl Callback error when I try to fit my EPR. What does that mean?

Ntasha

Newbie
Posts: 5
Joined: Wed Oct 25, 2017 8:57 am

Re: UIControl Callback

Post

by Ntasha » Thu Oct 26, 2017 8:16 am

Here is the full output

Error using magint
g tensor must be symmetric for this method.

Error in chili

Error in chili

Error in esfit

Error in esfit_simplex

Error in esfit

Error while evaluating UIControl Callback

I am trying to fit the diffusion angles (and the rates of rotation) of a spin labeled lipid inside a bilayer (powder spectra).
Here is my system setup

Nx =

g: [2.0086 2.0058 2.0020]
Nucs: ’14N’
A: [13.7000 13.7000 96.4000]
logDiff: [7.2500 8.8500]
DiffFrame: [6.2832 0.1745 0]

I am assuming that the spin label can rotate around its long axis freely (360degrees) and then wobble in the cone imposed by its environment. Some angles give me the error. I am not sure why.

Ntasha

Newbie
Posts: 5
Joined: Wed Oct 25, 2017 8:57 am

Re: UIControl Callback

Post

by Ntasha » Thu Oct 26, 2017 8:31 am

Attached is the example of the fitting I get

Attachments
Screen Shot 2017-10-26 at 10.19.21 AM.png
Screen Shot 2017-10-26 at 10.19.21 AM.png (321.8 KiB) Viewed 2078 times

katarkon

Local Expert
Posts: 157
Joined: Mon Jan 12, 2015 4:01 am

Re: UIControl Callback

Post

by katarkon » Sun Oct 29, 2017 7:36 am

Please give the script and exp data which causes the eror. Or alternatively try to run fitting with Opt.Verbosity=2. It gives much more information.

Stefan Stoll

EasySpin Creator
Posts: 971
Joined: Mon Jul 21, 2014 10:11 pm
Location: University of Washington

Re: UIControl Callback

Post

by Stefan Stoll » Thu Nov 02, 2017 1:39 pm

Also make sure to test this with the latest version of EasySpin (see the website). If you are using an older version, it might be that this is a bug that was already fixed.

У меня есть сценарий MATLAB, который отлично работал; никаких проблем с этим не было. Затем я переместил его в набор инструментов MATLAB и добавил в кеш, чтобы я мог легко запустить его из командной строки.

Однако теперь, когда я переместил его в панель инструментов, я получаю эти сообщения об ошибках! Никаких изменений в сценарий или что-то в этом роде. Я переместил с ним все подпапки и другие файлы, связанные со сценарием.

Понятия не имею, почему он выдает это сообщение об ошибке. Хуже того, он не делает это каждый раз, когда я запускаю скрипт! Иногда, если я закрываю MATLAB и открываю его снова, сценарий работает нормально. Иногда все, что мне нужно сделать, это щелкнуть что-нибудь в графическом интерфейсе, и это сработает! Но в следующий раз не будет? Вы можете мне помочь?

Это два сообщения об ошибках, которые он мне дает:

??? Too many outputs requested.  Most likely cause is missing [] around
left hand side that has a comma separated list expansion.

Error in ==> trials at 13
picture1 = files1.name;

Error in ==> semjudge>TRIAL_Callback at 285
trials;

??? Error using ==> waitfor
Error while evaluating uicontrol Callback

А также:

??? Error using ==> nchoosek at 31
The first argument has to be a scalar or a vector.

Error in ==> semjudge>START_Callback at 194
combos = nchoosek(1:nFiles, 2);

??? Error using ==> waitfor
Error while evaluating uicontrol Callback

Что вызывает эти ошибки, такие, что они появляются только ИНОГДА (без каких-либо изменений в файле .m, графическом интерфейсе пользователя или чем-то еще …)?

Это меня безмерно расстраивает. Он работал отлично и останавливался, несмотря на то, что никаких изменений не производилось. И непоследовательно, дает ли это мне ошибку. Я не могу найти никакой закономерности, когда это работает, а когда нет. И ни одна из ошибок, которые он ДЕЙСТВИТЕЛЬНО дает мне, не имеет для меня никакого смысла.

Файлы .m слишком длинные для публикации здесь, поэтому вы можете увидеть их здесь:

http://textuploader.com/?p=6&id=cKokK (семсуд.м)
http://textuploader.com/?p=6&id=vB9sD (испытания. м)

Вопрос:

У меня есть 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))).

Понравилась статья? Поделить с друзьями:
  • Matlab error bar plot
  • Master gas seoul ошибка а7
  • Matlab catch error
  • Master connection error перевод
  • Matkompas dll error 193