Parse error at')':

조회 수: 15 (최근 30일)
Zefanya Rumpesak
Zefanya Rumpesak 2020년 11월 16일
댓글: Zefanya Rumpesak 2020년 11월 16일
i got 3 errors here:
  • the function keyword use is invalid here
  • parse error at ')':
  • parse error at ELSE:
can somebody tell me how to fix this
pilih=get(handles.uibuttongroup1, 'Value');
handles.pilih=pilih;
guidata(hObject, handles)
if(pilih==1)
function[G] = ambang(F,t);
[m,n] = size(F);
for i = 1:m
for j = 1:n
if F(i,j) <=t
G(i,j) = 0;
else
G(i,j) = 1;
end
end
end
end
else if (pilih==2)
function[G] = arasjamak(F,t1,t2)
[m,n] = size(F);
for i = 1:m
for j = 1:n
if F(i,j) <=t1 || F(i,j) >=t2
G(i,j) = 0;
else
G(i,j) = 1;
end
end
end
end
else if(pilih==3)
level = graythresh(j);
BW = im2bw(j,level);
imshow(BW);
end

채택된 답변

Cris LaPierre
Cris LaPierre 2020년 11월 16일
편집: Cris LaPierre 2020년 11월 16일
You cannot define a function inside an if statement. If you want to include a helper function, ir must be defined at the bottom of your script, or in a separate file. See here for more.
  댓글 수: 1
Zefanya Rumpesak
Zefanya Rumpesak 2020년 11월 16일
Thanks! very helpful!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by