If Else statement problem

21 visualizaciones (últimos 30 días)
Haseeb Khan
Haseeb Khan el 22 de Oct. de 2017
Editada: KL el 22 de Oct. de 2017
if(P1>=P1min)&(P1<=P1max)
fprintf 'Machine 1 is in limits'
*elseif*
(P2>=P2min)&(P2<=P2max)
fprintf 'Machine 2 is in limits'
else
P1=P1max
P2=pd-(P1max+P3min)
P3=P3min
end
end
end
What is the error in ELSE IF statement. matlab gives me this error
"Expression or statement is incomplete or incorrect."

Respuestas (1)

KL
KL el 22 de Oct. de 2017
Editada: KL el 22 de Oct. de 2017
The syntax is very simple,
if (P1>=P1min) && (P1<=P1max)
fprintf 'Machine 1 is in limits'
elseif (P2>=P2min) && (P2<=P2max)
fprintf 'Machine 2 is in limits'
else
P1=P1max
P2=pd-(P1max+P3min)
P3=P3min
end
you only need one 'end'.

Categorías

Más información sobre Random Number Generation 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