How is a logical array evaluated as an if condition?
17 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Guido Gervasio
el 17 de Mzo. de 2017
Respondida: Steven Lord
el 17 de Mzo. de 2017
For example:
if logical([0, 0, 1)])
% code
end
0 comentarios
Respuesta aceptada
Steven Lord
el 17 de Mzo. de 2017
" if expression, statements, end evaluates an expression, and executes a group of statements when the expression is true. An expression is true when its result is nonempty and contains only nonzero elements (logical or real numeric). Otherwise, the expression is false."
Your vector logical([0 0 1]) is nonempty, but it does not contain only nonzero elements. So the expression is false and the body of your if statement is not executed.
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Data Types 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!