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!