Parentheses in code to make code more readable

3 vues (au cours des 30 derniers jours)
doron kra
doron kra le 2 Juin 2020
Commenté : Steven Lord le 2 Juin 2020
Hi,
i need to write a function and i'm using a few if-else or switch-case and the code starts to be difficult to read.
question: how do i bundle if-else or switch-case with Parentheses to make the code more readable?
thank you :-)

Réponse acceptée

madhan ravi
madhan ravi le 2 Juin 2020
Modifié(e) : madhan ravi le 2 Juin 2020
You can’t create a paranthesis like that in a code. I suggest you to make those two conditional statements as two separate functions?
  1 commentaire
doron kra
doron kra le 2 Juin 2020
i understand.
thank you for answering

Connectez-vous pour commenter.

Plus de réponses (1)

Steven Lord
Steven Lord le 2 Juin 2020
You might be interested in enabling code folding for your if/else blocks and/or your switch/case blocks in the Editor/Debugger preferences. This will give you a visual indicator of where each of those blocks begin and end and will enable you to put them "out of sight, out of mind" once you've finished writing them by hiding the body of those constructs.
  2 commentaires
madhan ravi
madhan ravi le 2 Juin 2020
Wow I thought , code folding was only for functions, looks like it’s even available for sections, cool!
Steven Lord
Steven Lord le 2 Juin 2020
It's not enabled by default for if or switch, but it can be enabled for them.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Simulink Functions dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by