how to solve a error llegal use of reserved keyword "else
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (2)
the cyclist
am 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 Kommentare
Star Strider
am 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 Kommentare
Siehe auch
Kategorien
Mehr zu Mapping Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!