Error using nargin ,You can only call nargin/nargout from within a MATLAB function.

3 visualizzazioni (ultimi 30 giorni)
When im running GUI code getting an error like this
"Error using nargin You can only call nargin/nargout from within a MATLAB function. " please help me how to slove this here my code is :
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @gui_OpeningFcn, ...
'gui_OutputFcn', @gui_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 gui_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
function varargout = gui_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
function inp_img_Callback(hObject, eventdata, handles)
cd TestIm
[filename, pathname] = uigetfile('*.jpg;*.bmp','Pick an Image File');
image = imread(filename);
cd ..
axes(handles.axes1);
imshow(image);
title('Input Image');
handles.image=image;
guidata(hObject, handles);
function gray_image_Callback(hObject, eventdata, handles)
image=handles.image;
im=imresize(image,[256 256]);
[r c p] = size(im);
if p==3
im = rgb2gray(im);
end
en_mask = [0 -1 0;-1 5 -1;0 -1 0];
im = imfilter(im,en_mask,'conv');
axes(handles.axes2);
imshow(im);
title('Input GrayScale Image');
im = double(im);
handles.im=im;
guidata(hObject, handles)
function dwt_pro_Callback(hObject, eventdata, handles)
im=handles.im;
[D11 D12 D13 D14] = dwt2(im,'db4');
Ls = liftwave('haar','Int2Int');
[D15 D16 D17 D18] = lwt2(im,Ls);
dec1 = [D11 D12;D13 D14];
dec2 = [D15 D16;D17 D18];
axes(handles.axes3);
imshow(dec1,[]);
title('Wavelet:Lifting db Decomposition');
axes(handles.axes4);
imshow(dec2,[]);
title('Wavelet:Lifting haar Decomposition');
gm1 = graycomatrix(D11);
gprops1 = graycoprops(gm1);
F1(1) = gprops1.Contrast; F1(2) = gprops1.Correlation;
F1(3) = gprops1.Energy; F1(4) = gprops1.Homogeneity;
gm2 = graycomatrix(D12);
gprops2 = graycoprops(gm2);
F2(1) = gprops2.Contrast; F2(2) = gprops2.Correlation;
F2(3) = gprops2.Energy; F2(4) = gprops2.Homogeneity;
gm3 = graycomatrix(D13);
gprops3 = graycoprops(gm3);
F3(1) = gprops3.Contrast; F3(2) = gprops3.Correlation;
F3(3) = gprops3.Energy; F3(4) = gprops3.Homogeneity;
gm4 = graycomatrix(D14);
gprops4 = graycoprops(gm4);
F4(1) = gprops4.Contrast; F4(2) = gprops4.Correlation;
F4(3) = gprops4.Energy; F4(4) = gprops4.Homogeneity;
gm5 = graycomatrix(D15);
gprops5 = graycoprops(gm5);
F5(1) = gprops5.Contrast; F5(2) = gprops5.Correlation;
F5(3) = gprops5.Energy; F5(4) = gprops5.Homogeneity;
gm6 = graycomatrix(D16);
gprops6 = graycoprops(gm6);
F6(1) = gprops6.Contrast; F6(2) = gprops6.Correlation;
F6(3) = gprops6.Energy; F6(4) = gprops6.Homogeneity;
gm7 = graycomatrix(D17);
gprops7 = graycoprops(gm7);
F7(1) = gprops7.Contrast; F7(2) = gprops7.Correlation;
F7(3) = gprops7.Energy; F7(4) = gprops7.Homogeneity;
gm8 = graycomatrix(D18);
gprops8 = graycoprops(gm8);
F8(1) = gprops8.Contrast; F8(2) = gprops8.Correlation;
F8(3) = gprops8.Energy; F8(4) = gprops8.Homogeneity;
qfeat = [F1 F2 F3 F4 F5 F6 F7 F8]';
nan_qv= isnan(qfeat);
qfeat(find(nan_qv== 1)) = 0;
disp('Query Features Set: ');
disp(qfeat);
handles.gm5=gm5;
handles.qfeat=qfeat;
guidata(hObject, handles);
function data_pro_Callback(hObject, eventdata, handles)
qfeat=handles.qfeat;
tic;
lda = waitbar(0,'Db Loading....');
Nsamples = 25;
for ti = 1:1:Nsamples
trfile = strcat(num2str(ti),'.jpg');
cd trsamples
tname = imread(trfile);
cd ..
tname = imresize(tname,[256,256]);
if size(tname,3)>1
tname= rgb2gray(tname);
end
en_mask = [0 -1 0;-1 5 -1;0 -1 0];
tname = imfilter(tname,en_mask,'conv');
[D11 D12 D13 D14] = dwt2(tname,'db4');
Ls = liftwave('haar','Int2Int');
[D15 D16 D17 D18] = lwt2(double(tname),Ls);
gm1 = graycomatrix(D11);
gprops1 = graycoprops(gm1);
F1(1) = gprops1.Contrast; F1(2) = gprops1.Correlation;
F1(3) = gprops1.Energy; F1(4) = gprops1.Homogeneity;
gm2 = graycomatrix(D12);
gprops2 = graycoprops(gm2);
F2(1) = gprops2.Contrast; F2(2) = gprops2.Correlation;
F2(3) = gprops2.Energy; F2(4) = gprops2.Homogeneity;
gm3 = graycomatrix(D13);
gprops3 = graycoprops(gm3);
F3(1) = gprops3.Contrast; F3(2) = gprops3.Correlation;
F3(3) = gprops3.Energy; F3(4) = gprops3.Homogeneity;
gm4 = graycomatrix(D14);
gprops4 = graycoprops(gm4);
F4(1) = gprops4.Contrast; F4(2) = gprops4.Correlation;
F4(3) = gprops4.Energy; F4(4) = gprops4.Homogeneity;
gm5 = graycomatrix(D15);
gprops5 = graycoprops(gm5);
F5(1) = gprops5.Contrast; F5(2) = gprops5.Correlation;
F5(3) = gprops5.Energy; F5(4) = gprops5.Homogeneity;
gm6 = graycomatrix(D16);
gprops6 = graycoprops(gm6);
F6(1) = gprops6.Contrast; F6(2) = gprops6.Correlation;
F6(3) = gprops6.Energy; F6(4) = gprops6.Homogeneity;
gm7 = graycomatrix(D17);
gprops7 = graycoprops(gm7);
F7(1) = gprops7.Contrast; F7(2) = gprops7.Correlation;
F7(3) = gprops7.Energy; F7(4) = gprops7.Homogeneity;
gm8 = graycomatrix(D18);
gprops8 = graycoprops(gm8);
F8(1) = gprops8.Contrast; F8(2) = gprops8.Correlation;
F8(3) = gprops8.Energy; F8(4) = gprops8.Homogeneity;
Dtemp = [F1 F2 F3 F4 F5 F6 F7 F8]';
dfeatures(:,ti) = Dtemp;
waitbar(ti/Nsamples,lda);
end
close(lda);
nan_val= isnan(dfeatures);
dfeatures(find(nan_val== 1)) = 0;
Bfeat = [];
for i = 1:1:size(dfeatures,2)
q = dfeatures(:,i);
temp = sqrt(sum((qfeat - q ).^2));
Bfeat = [Bfeat temp];
end
[relfeat , tbi] = min(Bfeat);
selq = dfeatures(:,tbi);
helpdlg('Database Loading Completed');
handles.dfeatures=dfeatures;
guidata(hObject, handles);
function tri_pro_Callback(hObject, eventdata, handles)
dfeatures=handles.dfeatures;
Nc =3; T =1;
for ti=1:1:size(dfeatures,2)
if Nc<1
T= T+1;
Nc= 2;
else
Nc= Nc-1;
end
deval(:,ti) = T;
end
disp(deval);
vdeval = ind2vec(deval);
netp = newpnn(dfeatures,vdeval);
helpdlg('Training Process Completed');
toc
handles.netp=netp;
guidata(hObject, handles);
function cla_pro_Callback(hObject, eventdata, handles)
im=handles.im;
gm5=handles.gm5;
netp=handles.netp;
qfeat=handles.qfeat;
dout = sim(netp,qfeat);
dout = vec2ind(dout);
if isequal(dout,1)
set(handles.text7,'String','Normal');
else
set(handles.text7,'String','Diseased');
end
[m n]=size(im);
gm5=imresize(gm5,[256 256]);
Tp=1;
for i=1:m
for j=1:n
if (im(i,j)==1 && gm5(i,j)==1)
Tp=Tp+1;
end
end
end
disp('Tp value');
disp(Tp);
Tn=0;
for i=1:m
for j=1:n
if (im(i,j)==0 && gm5(i,j)==0 )
Tn=Tn+1;
end
end
end
disp('Tn value');
disp(Tn);
Fp=0;
for i=1:m
for j=1:n
if (im(i,j)==1 && gm5(i,j)==0 )
Fp=Fp+1;
end
end
end
disp('Fp value');
disp(Fp);
Fn=1;
for i=1:m
for j=1:n
if (im(i,j)==0 && gm5(i,j)==1 )
Fn=Fn+1;
end
end
end
disp('Fn value');
disp(Fn);
Sensitivity = (Tp./(Tp+Fn)).*100;
Specificity = (Tn./(Tn+Fp)).*100;
Accuracy = ((Tp+Tn)./(Tp+Tn+Fp+Fn)).*100;
Precision=(Tp./(Tp+Fp)).*100;
FMeasure=(2*Precision*Sensitivity./(Precision+Sensitivity));
set(handles.edit1,'string',Sensitivity);
set(handles.edit2,'string',Specificity);
set(handles.edit3,'string',Accuracy);
set(handles.edit4,'string',Precision);
set(handles.edit5,'string',FMeasure);
function edit1_Callback(hObject, eventdata, handles)
function edit1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit2_Callback(hObject, eventdata, handles)
function edit2_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
featselc function:
function selq = featselc
load dfeatures;
load qfeat;
Bfeat = [];
for i = 1:1:size(dfeatures,2)
q = dfeatures(:,i);
temp = sqrt(sum((qfeat - q ).^2));
Bfeat = [Bfeat temp];
end
[relfeat , tbi] = min(Bfeat);
selq = dfeatures(:,tbi);
return;
nnlearn function:
function netp = nnlearn
tic;
lda = waitbar(0,'Db Loading....');
Nsamples = 25;
for ti = 1:1:Nsamples
trfile = strcat(num2str(ti),'.jpg');
cd trsamples
tname = imread(trfile);
cd ..
tname = imresize(tname,[256,256]);
if size(tname,3)>1
tname= rgb2gray(tname);
end
en_mask = [0 -1 0;-1 5 -1;0 -1 0];
tname = imfilter(tname,en_mask,'conv');
[D11 D12 D13 D14] = dwt2(tname,'db4');
Ls = liftwave('haar','Int2Int');
[D15 D16 D17 D18] = lwt2(double(tname),Ls);
gm1 = graycomatrix(D11);
gprops1 = graycoprops(gm1);
F1(1) = gprops1.Contrast; F1(2) = gprops1.Correlation;
F1(3) = gprops1.Energy; F1(4) = gprops1.Homogeneity;
gm2 = graycomatrix(D12);
gprops2 = graycoprops(gm2);
F2(1) = gprops2.Contrast; F2(2) = gprops2.Correlation;
F2(3) = gprops2.Energy; F2(4) = gprops2.Homogeneity;
gm3 = graycomatrix(D13);
gprops3 = graycoprops(gm3);
F3(1) = gprops3.Contrast; F3(2) = gprops3.Correlation;
F3(3) = gprops3.Energy; F3(4) = gprops3.Homogeneity;
gm4 = graycomatrix(D14);
gprops4 = graycoprops(gm4);
F4(1) = gprops4.Contrast; F4(2) = gprops4.Correlation;
F4(3) = gprops4.Energy; F4(4) = gprops4.Homogeneity;
gm5 = graycomatrix(D15);
gprops5 = graycoprops(gm5);
F5(1) = gprops5.Contrast; F5(2) = gprops5.Correlation;
F5(3) = gprops5.Energy; F5(4) = gprops5.Homogeneity;
gm6 = graycomatrix(D16);
gprops6 = graycoprops(gm6);
F6(1) = gprops6.Contrast; F6(2) = gprops6.Correlation;
F6(3) = gprops6.Energy; F6(4) = gprops6.Homogeneity;
gm7 = graycomatrix(D17);
gprops7 = graycoprops(gm7);
F7(1) = gprops7.Contrast; F7(2) = gprops7.Correlation;
F7(3) = gprops7.Energy; F7(4) = gprops7.Homogeneity;
gm8 = graycomatrix(D18);
gprops8 = graycoprops(gm8);
F8(1) = gprops8.Contrast; F8(2) = gprops8.Correlation;
F8(3) = gprops8.Energy; F8(4) = gprops8.Homogeneity;
Dtemp = [F1 F2 F3 F4 F5 F6 F7 F8]';
dfeatures(:,ti) = Dtemp;
waitbar(ti/Nsamples,lda);
end
close(lda);
nan_val= isnan(dfeatures);
dfeatures(find(nan_val== 1)) = 0;
save dfeatures dfeatures;
Nc =3; T =1;
for ti=1:1:size(dfeatures,2)
if Nc<1
T= T+1;
Nc= 2;
else
Nc= Nc-1;
end
deval(:,ti) = T;
end
disp(deval);
vdeval = ind2vec(deval)
netp = newpnn(dfeatures,vdeval);
save netp netp;
helpdlg('Training Process Completed');
toc
return;
end
  4 Commenti
Stephen23
Stephen23 il 19 Lug 2017
Modificato: Stephen23 il 19 Lug 2017
@DB: Do both of these:
  1. fix the code alignment, which is currently quite awful and can easily hide bugs, by clicking selecting all code and clicking ctrl+i. You should always use the default alignment.
  2. Then check that each function, if, etc is aligned with an end. You will likely find that one of them is missing, and the messy alignment makes it easy to hide this.
Adam
Adam il 19 Lug 2017
As a GUIDE function none of the functions should have an end unless you manually add one to the end of every one which would be insane (I did it once, years ago and quickly decided it was a stupid idea!!)

Accedi per commentare.

Risposte (1)

Jan
Jan il 18 Lug 2017
There are many orange an even red bars on the left side. Start with fixing them from top to bottom, because so errors may cause problems in the following source.
The message means, that the nargin is used outside a function. Perhaps there is a typo in the initial "function" in the first line?
  1 Commento
Adam
Adam il 18 Lug 2017
That first function is underlined in red too so the nargin error is just a red herring.
Maybe a function lower down has an end keyword at the end of it if you created your own function. I have accidentally done this sometimes.

Accedi per commentare.

Categorie

Scopri di più su Interactive Control and Callbacks in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by