how to solve a error llegal use of reserved keyword "else
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (2)
the cyclist
el 23 de Ag. de 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 comentarios
Star Strider
el 23 de Ag. de 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 comentarios
Ver también
Categorías
Más información sobre Mapping Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!