- Separate code into sections and run manually: You can move the code with errors into separate sections and then run each section manually. This ensures that the error is logged in side panel for each faulty section and rest of the code works fine with output shown correctly. Following that, export command can be used to generate a PDF since this command does not re-run the code.
- Use try/catch block: You many also use try/catch blocks to add the faulty code into try block and use the catch block to display the error message. This ensures code keeps running even if there are any errors.
Publish pdf with code error
2 views (last 30 days)
Show older comments
I have a mlx file with some text and a few lines of code. I deliberately wrote a few code instructions I expect to return an error, to show to the reader those errors. However, the code after the error is not shown. How do I print every command that does not return an error and explicitly leave the error on the wrong commands?
0 Comments
Answers (1)
Aniket
on 11 Jun 2025
I understand you want to export a PDF file from an .mlx file without interrupting on an error in between. The default behaviour of an .mlx file is to stop code exceution as soon as an error is encountered. However, there are 2 possible options to generate PDF even if the code has errors:
Please find more details regarding export command in this documentation: https://www.mathworks.com/help/matlab/ref/export.html
I hope this helps achieve the desired functionality!
0 Comments
See Also
Categories
Find more on Adding custom doc in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!