Error : Function definition is misplaced or improperly nested.
Ältere Kommentare anzeigen
here the code.
[filename,pathname] = uigetfile({'*'})
if ~isequal(filename,0)
info = imginfo(fullfile(pathname,filename));
if info.BitDepth == 1
msgbox('Citra harus RGB atau Grayscale');
return
else if info.BitDepth == 8
Img = imread(fullfile(pathname,filename));
axes(handles.axes1)
cla('reset')
imshow(Img)
title('Grayscale Image')
else
Img = rgb2gray(imread(fullfile(pathname,filename)));
axes(handles.axes1)
cla('reset')
imshow(Img)
title('Grayscale Image')
end
return
end
handles.Img = Img;
guidata(hObject,handles);
5 Kommentare
Geoff Hayes
am 28 Apr. 2019
suoh - please show the full error message. also provide some context for the above code: is it the body of a function? if so, what is the function signature and where is it defined relative to the rest of the code?
suoh mikoto
am 28 Apr. 2019
Geoff Hayes
am 28 Apr. 2019
I think that one problem might be with your "else if". In MATLAB, there isn't a space and so this is just "elseif". The way you have it right now suggests that you have an else block followed by another if/else block which would need to be terminated with an end just like the previous two if blocks... but you only have two ends which might then be the source of the error.
Geoff Hayes
am 28 Apr. 2019
For sure the last two lines are out of place and should be in the body of the block that defines the Img. And your first if block is missing an end.
suoh mikoto
am 28 Apr. 2019
Antworten (1)
Geoff Hayes
am 28 Apr. 2019
0 Stimmen
suoh - I think that one problem might be with your "else if". In MATLAB, there isn't a space and so this is just "elseif". The way you have it right now suggests that you have an else block followed by another if/else block which would need to be terminated with an end just like the previous two if blocks... but you only have two ends which might then be the source of the error.
For sure the last two lines are out of place and should be in the body of the block that defines the Img. And your first if block is missing an end.
Kategorien
Mehr zu Matrix Indexing finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!