- 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 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Aniket
2025 年 6 月 11 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Adding custom doc についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!