how to solve a error llegal use of reserved keyword "else
조회 수: 1 (최근 30일)
이전 댓글 표시
In my code i am getting this error llegal use of reserved keyword "else and i am unable to solve it my code inputs image converts it into grayscale and resizes it into 64x64 matrix which is then converted to 8x8 matrix containing the following parameters 0-total damage in the terrain 1-moderate damage in the terrain 2- no damage with these values and the start and the destination values the points in the path are got here is my code. the code is enclosed named matlab text
ccan help me in solving this problem
댓글 수: 0
답변 (2개)
the cyclist
2015년 8월 23일
The problem begins in this section of your code:
% Direction analysis %
if (end_col < p2)
if ((M(p1, row) == 2)||(M(p1,row)==1))
path_row(row_trace) = row;
path_col(col_trace) = p1;
found = 1;
elseif((M(p2, row) == 2)||(M(p2,row)==1))
path_row(row_trace) = row;
path_col(col_trace) = p2;
found = 1;
elseif((M(p3, row) == 2)||(M(p3,row)==1))
path_row(row_trace) = row;
path_col(col_trace) = p3;
found = 1;
end
end
else
See that else sitting there? It is outside of the logic of the previous if ... end structure.
I can't figure out exactly what your intention was, so I can't see how to fix it.
댓글 수: 0
Star Strider
2015년 8월 23일
NOTE:
else if(M(p2,row)==0)
From the documentation on if:
- Avoid adding a space after else within the elseif keyword (else if). The space creates a nested if statement that requires its own end keyword.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Mapping Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!