how to solve a error llegal use of reserved keyword "else
1 view (last 30 days)
Show older comments
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 Comments
Answers (2)
the cyclist
on 23 Aug 2015
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 Comments
Star Strider
on 23 Aug 2015
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 Comments
See Also
Categories
Find more on Mapping Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!