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.

This is wrong:

a=get(handles.slider1,'Min',1,'Max',10,'Value',1);

You can either do:

a_min=get(handles.slider1,'Min');
a_max=get(handles.slider1,'Max');
a_val=get(handles.slider1,'Value');

if you want to get the properties of the uicontrol, or:

a=set(handles.slider1,'Min',1,'Max',10,'Value',1);

if you want to set the properties of the uicontrol.

EDIT following comments:

It sounds as if you want to display the current value of the slider in an edit text box. Then you need to do:

a_val=get(handles.slider1,'Value');
str=sprintf('Slider value %f',a_val); 
set(handles.text1,'String',str);

Make sure your questions are well posed and self-contained, we can’t guess what it is you are trying to do unless you actually tell us.

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
function varargout = Kursath(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @Kursath_OpeningFcn, ...
                   'gui_OutputFcn',  @Kursath_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
 
function Kursath_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
 
function varargout = Kursath_OutputFcn(hObject, eventdata, handles) 
varargout{1} = handles.output;
 
 
function pushbutton1_Callback(hObject, eventdata, handles)
x(1)=handles.metricdata.x0;
u=handles.metricdata.xn;
i=1;
h=handles.metricdata.h;
while x(i)<u
    x(i+1)=x(i)+h;
    i=i+1;
end
handles.metricdata.x=x;
f=handles.metricdata.Fx;
y(1)=handles.metricdata.Yo;
for i=2:length(x)
    if i-1>0
        df=f(i)-f(i-1);
    else
        df=0;
    end
    if i-2>0
        d2f=f(i)-2*f(i-1)+f(i-2);
    else
        d2f=0;
    end
    if i-3>0
        d3f=f(i)-3*f(i-1)+3*f(i-2)-f(i-3);
    else
        d3f=0;
    end
    y(i)=y(i-1)+h*f(i-1)+(((h.^2)/2)*df)+(((5*h.^3)/12)*d2f)+(((3*h.^4)/8)*d3f);
end
handles.metricdata.y = y;
guidata(hObject,handles)
axes(handles.axes1);
cla;
plot(x,y);
function pushbutton2_Callback(hObject, eventdata, handles)
e(1,:)=handles.metricdata.x;
e(2,:)=handles.metricdata.y;
d=uiputfile('*.txt','Save Workspace As');
dlmwrite(d,e,'delimiter', 't', 'precision', 6);
 
function pushbutton3_Callback(hObject, eventdata, handles)
initialize_gui(gcbf, handles, true);
function initialize_gui(fig_handle, handles, isreset)
if isfield(handles, 'metricdata') && ~isreset
    return;
end
handles.metricdata.x0 = 0;
handles.metricdata.xn = 0;
handles.metricdata.h = 0;
handles.metricdata.Fx = 0;
handles.metricdata.Yo = 0;
set(handles.Yo, 'String', handles.metricdata.Yo);
set(handles.x0, 'String', handles.metricdata.x0);
set(handles.xn,  'String', handles.metricdata.xn);
set(handles.h,  'String', handles.metricdata.h);
set(handles.Fx,  'String', handles.metricdata.Fx);
cla;
guidata(fig_handle,handles)
 
function Yo_Callback(hObject, eventdata, handles)
Yo = str2num(get(hObject, 'String'));
handles.metricdata.Yo = Yo;
guidata(hObject,handles)
 
function Yo_CreateFcn(hObject, eventdata, handles)
 
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
 
function h_Callback(hObject, eventdata, handles)
h = str2num(get(hObject, 'String'));
handles.metricdata.h = h;
guidata(hObject,handles)
 
function h_CreateFcn(hObject, eventdata, handles)
 
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
 
function Fx_Callback(hObject, eventdata, handles)
F = get(hObject, 'String');
Fx=inline(F);
handles.metricdata.Fx = Fx;
guidata(hObject,handles)
 
function Fx_CreateFcn(hObject, eventdata, handles)
 
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
 
function xn_Callback(hObject, eventdata, handles)
xn = str2num(get(hObject, 'String'));
handles.metricdata.xn = xn;
guidata(hObject,handles)
 
function xn_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
 
function x0_Callback(hObject, eventdata, handles)
x0 = str2num(get(hObject, 'String'));
handles.metricdata.x0 = x0;
guidata(hObject,handles)
 
function x0_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
 
function pushbutton4_Callback(hObject, eventdata, handles)
Close
 
function pushbutton5_Callback(hObject, eventdata, handles)
helpdlg('   Данная программа позволяет решить обыкновенное дифференциальное уравнение многошаговым методом Адамса. Имея в распоряжении отрезок, на котором будет считаться дифференциал, закон распространения значений правой части и начальное значение дифференциального уравнения. Например: имеется функция f(x), х0, шаг, хn и Y(x0), многошаговый метод Адамса позволяет вычислить последующие значения дифференциального уравнения на заданном отрезке.                                                             ДЛЯ РАСЧЕТА НЕОБХОДИМО:                                                                                               1)  Ввести поле "x0" начальное значения x от которого начнутся вычисления, в поле "xn" ввести последнее значение x, до которого будут ввестись подсчеты и ввести в поле "h" шаг, который будет показывать точность измерений. В поле "Yo" записываем первое значение дифференциального уравнения при x0.                                                                     2)     В поле f(x) введите закон распределения правой части дифференциального уравнения (не забудьте перед / и ^ ставить. Закон распределения нужно вводить через переменную x.)                                                                                                                                     3)  Нажать на кнопку "Рассчитать" (искомое значение отобразиться на графике).                                                        ПРИМЕЧАНИЕ: При нажатии на кнопку "Обнулить все поля", во всех полях будут значения равные нулю, т.е. произойдет сброс введенных данных. Можно сохранить результат, нажав на кнопку "Сохранить", при её нажатии появится "окно-проводник", где можно по своему усмотрению выбрать место для сохранения и имя сохраняемого файла. При нажатии кнопки "Выход" программа заканчивает свою работу и выходит из неё.','Справка');
 
function y_Callback(hObject, eventdata, handles)
set(handles.y, 'String', mat2str(y));
 
function y_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

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]

  • Error status invalid gpt 0xc0030008 ошибка sp flashtool
  • Error status ext ram exception 0xc0050005 ошибка flashtool как исправить
  • Error status brom cmd startcmd fail 0xc0060003 как исправить ошибку
  • Error status brom cmd startcmd fail 0xc0060001 как исправить ошибку
  • Error status brom cmd send da fail 0xc0060003 как исправить ошибку