At least one END is missing: the statement may begin here.

44 visualizaciones (últimos 30 días)
Jenice Chen
Jenice Chen el 26 de Dic. de 2018
Respondida: Monish V el 27 de Sept. de 2020
for p=1:size(case_matrix,1)
if case_matrix(p,1)==1
scatter(case_matrix(p,4),case_matrix(p,5),'s','r');
hold on;
elseif case_matrix(p,1)==2
scatter(case_matrix(p,4),case_matrix(p,5),'o','b');
hold on;
elseif case_matrix(p,1)==3
scatter(case_matrix(p,4),case_matrix(p,5),'m','*');
hold on;
if case_matrix(p,1)==4
scatter(case_matrix(p,4),case_matrix(p,5),'x','g ');
hold on;
end
end
Error: File: ConflictCase_2.m Line: 52 Column: 1
At least one END is missing: the statement may begin here.

Respuestas (4)

madhan ravi
madhan ravi el 26 de Dic. de 2018
Editada: madhan ravi el 26 de Dic. de 2018
See https://www.mathworks.com/help/matlab/ref/if.html (to better understand about if statements), when an if condition is used it needs to have an end
elseif case_matrix(p,1)==4
% ^^^^----- missed it

Steven Lord
Steven Lord el 16 de En. de 2019
Copy and paste this code into the MATLAB Editor. Select all that text, right-click, and select the "Smart Indent" menu option. This will line up each end keyword with the other keyword whose block it completes. Ideally, if there is a for, if, while, etc. starting in the first column of the first line, the final end on the last line should also start in the first column. For your code, it doesn't.
Looking at the code pattern I agree with KALYAN ACHARJYA's answer that your last case probably should start with elseif instead of if. When I make that change and smart indent the code, now the final end lines up with the for.

KALYAN ACHARJYA
KALYAN ACHARJYA el 26 de Dic. de 2018
Editada: KALYAN ACHARJYA el 26 de Dic. de 2018
for p=1:size(case_matrix,1)
if case_matrix(p,1)==1
scatter(case_matrix(p,4),case_matrix(p,5),'s','r');
hold on;
elseif case_matrix(p,1)==2
scatter(case_matrix(p,4),case_matrix(p,5),'o','b');
hold on;
elseif case_matrix(p,1)==3
scatter(case_matrix(p,4),case_matrix(p,5),'m','*');
hold on;
elseif case_matrix(p,1)==4
scatter(case_matrix(p,4),case_matrix(p,5),'x','g ');
hold on;
else
disp('No Condition is Satisfied');
end
end

Monish V
Monish V el 27 de Sept. de 2020
Error: File: lab.m Line: 11 Column: 1
At least one END is missing: the statement may begin here.

Categorías

Más información sobre Customize Object Indexing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by