Effacer les filtres
Effacer les filtres

what's the difference between | and || in matlab??

391 vues (au cours des 30 derniers jours)
maha ismail
maha ismail le 10 Déc 2014
Modifié(e) : Stephen23 le 19 Mar 2024
what's the difference between | and || in matlab??

Réponse acceptée

matt dash
matt dash le 10 Déc 2014
Déplacé(e) : Stephen23 le 19 Mar 2024
Clarification: for short circuit "and" no tests are evaluated after the first "false". For short circuit "or" no tests are evaluated after the first true.

Plus de réponses (1)

Sean de Wolski
Sean de Wolski le 10 Déc 2014
Modifié(e) : Sean de Wolski le 10 Déc 2014
| applies to each element in the array, || applies to a scalar condition:
[1 0 1] | [ 0 0 1]
v.
[1 0 1] || [ 0 0 1]
  1 commentaire
Stephen23
Stephen23 le 19 Mar 2024
Modifié(e) : Stephen23 le 19 Mar 2024
It is unclear to me what those code examples are supposed to clarify:
[1 0 1] | [0 0 1]
ans = 1×3 logical array
1 0 1
[1 0 1] || [0 0 1]
Operands to the logical AND (&&) and OR (||) operators must be convertible to logical scalar values. Use the ANY or ALL functions to reduce operands to logical scalar values.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Write Unit Tests dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by