Borrar filtros
Borrar filtros

Collapse Specific Sections that deal with debugging

101 visualizaciones (últimos 30 días)
Christopher Greulich
Christopher Greulich el 23 de En. de 2023
Respondida: Raghav el 9 de Mzo. de 2023
I've got a lot of if statments that control output for debuging. Is it possible to fold only specific statements that include my debugging variable.
For example I could have something like:
a = 3
b = 5
if b > a
output = doSomething(a,b);
end
if debug > 0
print(output.summary);
end
if debug > 1
print(output.detailed);
end
I would like to be able to automatically fold all the if statments that include the variable 'debug', but leave the statements that don't include the variable (like the first, if b>a).

Respuestas (1)

Raghav
Raghav el 9 de Mzo. de 2023
Hi,
Based on the question, I understand that you need to know about how code folding works in MATLAB editor.
I am not aware of any method to do the code folding based on a certain keyword in MATLAB.
However, what you can try is just to put the certain part which you want to fold in a section and turn on the code folding based on sections. To do that, adhere the following steps:
  1. Go to MATLAB > Home > Preferences.
  2. Go to MATLAB > Editor/Debugger > Code Folding
  3. Enable the Sections setting here.
  4. Click on “Apply” & then “OK”.
Now, whenever you want to fold a certain part of code then you can just put “%%” in the above line & it will create a section for that block. You can check to the below image for reference:
Hope that helps.
Regards,
Raghav Bansal

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by