現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
Getting Error in Matlab GUIDE
4 ビュー (過去 30 日間)
古いコメントを表示
I just want to press a button and have 'ok' print to an edit field, but I keep getting the following error after I click the button:
Undefined function or variable 'pushbutton1_Callback'.
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in PME_app2 (line 17)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)PME_app2('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback.
Code Below
function varargout = PME_app2(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @PME_app2_OpeningFcn, ...
'gui_OutputFcn', @PME_app2_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
% End initialization code - DO NOT EDIT
% --- Executes just before PME_app2 is made visible.
function PME_app2_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
end
% --- Outputs from this function are returned to the command line.
function varargout = PME_app2_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
end
function pushbutton1_Callback(hObject, eventdata, handles)
set(handles.edit1,'ok')
end
% --- Executes during object creation, after setting all properties.
function pushbutton1_CreateFcn(hObject, eventdata, handles)
% hObject handle to pushbutton1 (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
end
採用された回答
Walter Roberson
2018 年 2 月 23 日
Your code for function pushbutton1_Callback would either have to be inside PME_app2.m or else it would have to be in its own pushbutton1_Callback.m file in order to be found.
27 件のコメント
qiana curcuru
2018 年 2 月 23 日
It is inside PME_app2.m, I just updated the code, but still the same error.
Walter Roberson
2018 年 2 月 23 日
編集済み: Walter Roberson
2018 年 2 月 23 日
The problem is that you used nested functions. GUIDE uses str2func() to try to find the functions to execute, but https://www.mathworks.com/help/matlab/ref/str2func.html
"Function handles created using str2func do not have access to variables outside of their local workspace or to nested functions. If your function handle contains these variables or functions, MATLAB® throws an error when you invoke the handle. Also, if you use a text representation of an anonymous function, the resulting function handle does not have access to private or local functions."
So this restriction on str2func() is expected.
This does not mean you cannot use nested functions together with GUIDE, but it does mean that the functions named as callbacks must not be nested functions (but they can nest things.)
This is not exactly a restriction against using nested functions to create GUIs, but it is a restriction against using str2func() to create the function handles to such functions. This means that it would be legal to create explicit function handles in the source code and match on them to figure out which one to execute.
Also, you are missing edit1_CreateFcn
Walter Roberson
2019 年 10 月 30 日
What to do is rewrite the code so that you do not use nested functions.
Walter Roberson
2019 年 10 月 30 日
Datta Sai Raipally
2019 年 11 月 1 日
function varargout = main(varargin)
% MAIN M-file for main.fig
% MAIN, by itself, creates a new MAIN or raises the existing
% singleton*.
%
% H = MAIN returns the handle to a new MAIN or the handle to
% the existing singleton*.
%
% MAIN('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in MAIN.M with the given input arguments.
%
% MAIN('Property','Value',...) creates a new MAIN or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before main_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to main_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @main_OpeningFcn, ...
'gui_OutputFcn', @main_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
end
% End initialization code - DO NOT EDIT
% --- Executes just before main is made visible.
function main_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 main (see VARARGIN)
% Choose default command line output for main
handles.output = hObject;
a=ones(300,512);
axes(handles.axes1);
imshow(a);
axes(handles.axes2);
imshow(a);
% Update handles structure
guidata(hObject, handles);
end
% UIWAIT makes main wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = main_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;
end
% --- Executes on button press in playaudio.
function playaudio_Callback(hObject, eventdata, handles)
% hObject handle to playaudio (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
a=handles.a;
wavplay(a,44100);
end
% --- Executes on button press in exit.
function exit_Callback(hObject, eventdata, handles)
% hObject handle to exit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
exit;
end
% --- Executes on button press in inputaudio.
function inputaudio_Callback(hObject,eventdata, handles)
% hObject handle to inputaudio (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename, pathname] = uigetfile('*.wav', 'Pick an audio');
if isequal(filename,0) || isequal(pathname,0)
warndlg('Audio is not selected');
else
a=audioread(filename);
axes(handles.axes1);
plot(a);
% disp(a);
handles.filename=filename;
handles.a=a;
guidata(hObject, handles);
helpdlg('Input audio is Selected');
end
end
% --- Executes on button press in secretdata.
function secretdata_Callback(hObject, eventdata, handles)
% hObject handle to secretdata (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename, pathname] = uigetfile('*.txt', 'Pick any txt file');
if isequal(filename,0) || isequal(pathname,0)
warndlg('txt file is not selected');
else
fid = fopen(filename,'r');
F = fread(fid);
s = char(F');
fclose(fid);
end
handles.s=s;
handles.F=F;
guidata(hObject, handles);
helpdlg('Text File is Selected');
end
% --- Executes on button press in embedding.
function embedding_Callback(hObject, eventdata, handles)
% hObject handle to embedding (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
a=handles.a;
s=handles.s;
F=handles.F;
Q_SIZE = 3;
c=round(a*(10^Q_SIZE));
i=1;
ii=51;
while i <=length(s)
if c(ii,1)<0
sbit1 = -1;
else
sbit1 = 1;
end
iii = ii+2;
if c(iii,1)<0
sbit2 = -1;
else
sbit2 = 1;
end
c(ii,1) = abs(c(ii,1));
c(iii,1) = abs(c(iii,1));
[c(ii,1),c(iii,1)]=Enc_Char(c(ii,1),c(iii,1),F(i));
c(ii,1) = sbit1*c(ii,1);
c(iii,1) = sbit2*c(iii,1);
i=i+1;
ii = iii+2;
end
n = length(F); % Input Text Length
d=c/(10^Q_SIZE);
axes(handles.axes2);
plot(d);
audiowrite(d,44100,16,'Embedded.WAV');
helpdlg('Embedded process completed');
pass=passkey;
s2 = char(pass);
ss = length(s2);
if ss==4
helpdlg('Secret Key Sucessesfully added');
else
errordlg('Enter the Valid Secret Key');
end
num = dec2bin(s2,8);
disp(num);
handles.pass = num;
handles.d=d;
handles.n = n;
guidata(hObject, handles);
end
% --- Executes on button press in extraction.
function extraction_Callback(hObject, eventdata, handles)
% hObject handle to extraction (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
n=handles.n;
pass=handles.pass;
pass1=passkey;
s2 = char(pass1);
ss = length(s2);
if ss==4
helpdlg('Secret Key Sucessesfully added');
else
errordlg('Enter the Valid Secret Key');
end
pass1 = dec2bin(s2,8);
temp=0;
for i=1:4
for j=1:8
if pass(i,j)==pass1(i,j)
temp=temp+1;
else
temp = 0;
end
end
end
if temp == 32
%s='A';
%s1=serial('COM5','BaudRate',9600);
%fopen(s1);
%fprintf(s1,s);
%fclose(s1);
else
errordlg('Password missmached');
%s='B';
%s1=serial('COM5','BaudRate',9600);
%fopen(s1);
%fprintf(s1,s);
%fclose(s1);
exit;
end
a=wavread('Embedded.wav');
Q_SIZE = 3;
c=round(a*(10^Q_SIZE));
i = 1;
TXT_LENGTH = n;
ii=51;
while i <= TXT_LENGTH
c(ii,1) = abs(c(ii,1));
iii = ii+2;
c(iii,1) = abs(c(iii,1));
s(i)=Dec_Char(c(ii,1),c(iii,1));
i = i+1;
ii = iii+2;
end
fid = fopen('output.txt','wb');
fwrite(fid,char(s'),'char');
fclose(fid);
helpdlg('Extraction process completed');
end
% --- Executes on button press in viewoutput.
function viewoutput_Callback(hObject, eventdata, handles)
% hObject handle to viewoutput (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
open 'output.txt';
end
% --- Executes on button press in playaudio1.
function playaudio1_Callback(hObject, eventdata, handles)
% hObject handle to playaudio1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
d = handles.d;
wavplay(d,44100);
end
function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (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 edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double
end
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (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
end
function edit2_Callback(hObject, eventdata, handles)
% hObject handle to edit2 (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 edit2 as text
% str2double(get(hObject,'String')) returns contents of edit2 as a double
end
% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit2 (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
end
% --- Executes on button press in validation.
function validation_Callback(hObject, eventdata, handles)
% hObject handle to validation (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
inpaud = handles.a;
embaud = handles.d;
[Y,Z]=psnr(inpaud,embaud);
set(handles.edit1,'string',Y);
set(handles.edit2,'string',Z);
end
Image Analyst
2019 年 11 月 1 日
I can't tell what is wrong by looking at hundreds of lines of code -- I need to run it. Attach both the .m and .fig file with the paper clip icon and tell us exactly what needs to be corrected. the only thing wrong with it that I can see right off the bat is that you have not added any comments to explain it. If "correct" means to add comments and fix indentation, we are most likely not going to do that.
Walter Roberson
2019 年 11 月 2 日
function validation_Callback(hObject, eventdata, handles)
% hObject handle to validation (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
inpaud = handles.a;
embaud = handles.d;
[Y,Z]=psnr(inpaud,embaud);
set(handles.edit1,'string',Y);
set(handles.edit2,'string',Z);
end
You are using "end" statements corresponding to your "function" statements. GUIDE is not able to handle that. GUIDE requires that you not use "end" for each "function", and that you not use nested functions or shared variables -- at least not for the part of the code being managed by GUIDE.
Walter Roberson
2019 年 11 月 2 日
function varargout = main(varargin)
% MAIN M-file for main.fig
% MAIN, by itself, creates a new MAIN or raises the existing
% singleton*.
%
% H = MAIN returns the handle to a new MAIN or the handle to
% the existing singleton*.
%
% MAIN('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in MAIN.M with the given input arguments.
%
% MAIN('Property','Value',...) creates a new MAIN or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before main_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to main_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @main_OpeningFcn, ...
'gui_OutputFcn', @main_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
% End initialization code - DO NOT EDIT
% --- Executes just before main is made visible.
function main_OpeningFcn(hObject,~, 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 main (see VARARGIN)
% Choose default command line output for main
handles.output = hObject;
a=ones(300,512);
axes(handles.axes1);
imshow(a);
axes(handles.axes2);
imshow(a);
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes main wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = main_OutputFcn(~,~, 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 playaudio.
function playaudio_Callback(~, ~, handles) %#ok<DEFNU>
% hObject handle to playaudio (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
a=handles.a;
wavplay(a,44100);
% --- Executes on button press in exit.
function exit_Callback(~, ~, ~) %#ok<DEFNU>
% hObject handle to exit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
exit;
% --- Executes on button press in inputaudio.
function inputaudio_Callback(hObject,~, handles) %#ok<DEFNU>
% hObject handle to inputaudio (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename, pathname] = uigetfile('*.wav', 'Pick an audio');
if isequal(filename,0) || isequal(pathname,0)
warndlg('Audio is not selected');
else
a=audioread(filename);
axes(handles.axes1);
plot(a);
% disp(a);
handles.filename=filename;
handles.a=a;
guidata(hObject, handles);
helpdlg('Input audio is Selected');
end
% --- Executes on button press in secretdata.
function secretdata_Callback(hObject, ~, handles) %#ok<DEFNU>
% hObject handle to secretdata (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename, pathname] = uigetfile('*.txt', 'Pick any txt file');
if isequal(filename,0) || isequal(pathname,0)
warndlg('txt file is not selected');
else
fid = fopen(filename,'r');
F = fread(fid);
s = char(F');
fclose(fid);
end
handles.s=s;
handles.F=F;
guidata(hObject, handles);
helpdlg('Text File is Selected');
% --- Executes on button press in embedding.
function embedding_Callback(hObject, ~, handles) %#ok<DEFNU>
% hObject handle to embedding (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
a=handles.a;
s=handles.s;
F=handles.F;
Q_SIZE = 3;
c=round(a*(10^Q_SIZE));
i=1;
ii=51;
while i <=length(s)
if c(ii,1)<0
sbit1 = -1;
else
sbit1 = 1;
end
iii = ii+2;
if c(iii,1)<0
sbit2 = -1;
else
sbit2 = 1;
end
c(ii,1) = abs(c(ii,1));
c(iii,1) = abs(c(iii,1));
[c(ii,1),c(iii,1)]=Enc_Char(c(ii,1),c(iii,1),F(i));
c(ii,1) = sbit1*c(ii,1);
c(iii,1) = sbit2*c(iii,1);
i=i+1;
ii = iii+2;
end
n = length(F); % Input Text Length
d=c/(10^Q_SIZE);
axes(handles.axes2);
plot(d);
audiowrite(d,44100,16,'Embedded.WAV');
helpdlg('Embedded process completed');
pass=passkey;
s2 = char(pass);
ss = length(s2);
if ss==4
helpdlg('Secret Key Sucessesfully added');
else
errordlg('Enter the Valid Secret Key');
end
num = dec2bin(s2,8);
disp(num);
handles.pass = num;
handles.d=d;
handles.n = n;
guidata(hObject, handles);
% --- Executes on button press in extraction.
function extraction_Callback(~, ~, handles) %#ok<DEFNU>
% hObject handle to extraction (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
n=handles.n;
pass=handles.pass;
pass1=passkey;
s2 = char(pass1);
ss = length(s2);
if ss==4
helpdlg('Secret Key Sucessesfully added');
else
errordlg('Enter the Valid Secret Key');
end
pass1 = dec2bin(s2,8);
temp=0;
for i=1:4
for j=1:8
if pass(i,j)==pass1(i,j)
temp=temp+1;
else
temp = 0;
end
end
end
if temp == 32
%s='A';
%s1=serial('COM5','BaudRate',9600);
%fopen(s1);
%fprintf(s1,s);
%fclose(s1);
else
errordlg('Password missmached');
%s='B';
%s1=serial('COM5','BaudRate',9600);
%fopen(s1);
%fprintf(s1,s);
%fclose(s1);
exit;
end
a=audioreader('Embedded.wav');
Q_SIZE = 3;
c=round(a*(10^Q_SIZE));
i = 1;
TXT_LENGTH = n;
ii=51;
s = zeros(1,TXT_LENGTH);
while i <= TXT_LENGTH
c(ii,1) = abs(c(ii,1));
iii = ii+2;
c(iii,1) = abs(c(iii,1));
s(i)=Dec_Char(c(ii,1),c(iii,1));
i = i+1;
ii = iii+2;
end
fid = fopen('output.txt','wb');
fwrite(fid,char(s'),'char');
fclose(fid);
helpdlg('Extraction process completed');
% --- Executes on button press in viewoutput.
function viewoutput_Callback(~, ~, ~) %#ok<DEFNU>
% hObject handle to viewoutput (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
open 'output.txt';
% --- Executes on button press in playaudio1.
function playaudio1_Callback(~, ~, handles) %#ok<DEFNU>
% hObject handle to playaudio1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
d = handles.d;
sound(d,44100);
function edit1_Callback(~, ~, ~) %#ok<DEFNU>
% hObject handle to edit1 (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 edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, ~, ~) %#ok<DEFNU>
% hObject handle to edit1 (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
function edit2_Callback(~, ~, ~) %#ok<DEFNU>
% hObject handle to edit2 (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 edit2 as text
% str2double(get(hObject,'String')) returns contents of edit2 as a double
% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, ~, ~) %#ok<DEFNU>
% hObject handle to edit2 (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 validation.
function validation_Callback(~, ~, handles) %#ok<DEFNU>
% hObject handle to validation (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
inpaud = handles.a;
embaud = handles.d;
[Y,Z]=psnr(inpaud,embaud);
set(handles.edit1,'string',Y);
set(handles.edit2,'string',Z);
Walter Roberson
2019 年 11 月 2 日
https://www.mathworks.com/help/matlab/matlab_prog/nested-functions.html
Datta Sai Raipally
2019 年 11 月 5 日
sir..can I get ur mail please..I will send the complete code...please
Walter Roberson
2022 年 7 月 24 日
Enc_Char is not part of MATLAB. You will need to write it yourself or find place that it is already written such as the place you found Dec_Char
MAYUR KULAM
2022 年 7 月 24 日
編集済み: MAYUR KULAM
2022 年 7 月 24 日
Dec_char is also giving error as undeclared variable
Walter Roberson
2022 年 7 月 24 日
Dec_char is not present in your posted code. Your code refers to Dec_Char. We can see from your screen shot that you do not Dec_Char.m in your current directory.
Walter Roberson
2022 年 7 月 24 日
No. You should review your documentation about what Dec_Char and Enc_Char are expected to do, and you write functions that do those tasks.
MAYUR KULAM
2022 年 7 月 24 日
編集済み: MAYUR KULAM
2022 年 7 月 24 日
when i write the code in the function Enc_Char and Dec_Char and call it in imp.m then the above error occurs saying Execution of script Enc_Char as a function is not supported is there anyother way i can use it in my main code itself
Walter Roberson
2022 年 7 月 24 日
Remember that in MATLAB, there are three different types of .m files:
- a file in which the first non-comment is "function" is a function file
- a file in which the first non-comment is "classdef" is a class definition
- all other .m files are "script" files
The message is telling you that Dec_Char is a script file. It either has no "function" at all or else it has some code before the "function" statement. You need to fix the file to be a function file. (A file that contains only comments would also be considered a script file)
その他の回答 (2 件)
SRT HellKitty
2018 年 2 月 23 日
I'm not sure this will fix the error you are encountering, but when you set a textbox you need to use this context;
set(handles.edit1,'String','ok')
Image Analyst
2018 年 2 月 23 日
編集済み: Image Analyst
2018 年 2 月 23 日
In GUIDE, right click on the button and say "View Callbacks -> Callback". This will create the callback function that you need, and which your program is trying to execute but that does not exist yet (until you create it).
And get rid of the "end" statements in PME_app2_OpeningFcn() and pushbutton1_Callback().
If that doesn't work, also attach the .m file so we can fix it.
2 件のコメント
qiana curcuru
2018 年 2 月 23 日
I tried that, but it still didn't work, but I attached the original .m file. Thank you!!
Image Analyst
2018 年 2 月 23 日
Well it did work because the "ends" were making your function a nested function and you told Walter that once you fixed that, it worked.
参考
カテゴリ
Help Center および File Exchange で Migrate GUIDE Apps についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- 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
- United Kingdom (English)
アジア太平洋地域
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)