Print to PDF not showing outputs

40 Ansichten (letzte 30 Tage)
Kate
Kate am 19 Mär. 2025
Bearbeitet: Anjaneyulu Bairi am 19 Mär. 2025
When I try to use print to pdf on matlab, my entire code is displayed but my outputs that would show up in the command window will not show up. I've been using matlab for 2 years now and have never run into this issue. The outputs show up just fine in the command window, but as soon as I export it to a pdf it will only show the code itself. I have also tried using
publish(file, format)
Whenever I do this, matlab opens an infinite amount of figures displaying nothing and won't stop until I completely restart my computer. I genuinely have no idea whats wrong with it, I don't think I changed any settings or anything like that. I haven't seen any other questions similar to this so I'm hoping someone will be able to help me. I'm an engineering student so I really need my outputs to show up when I submit assigments. Any help is appreciated!

Antworten (1)

Anjaneyulu Bairi
Anjaneyulu Bairi am 19 Mär. 2025
Bearbeitet: Anjaneyulu Bairi am 19 Mär. 2025
Hi,
If you're unable to see the command outputs in your PDF file generated using the "publish" command, it could be due to several reasons related to the "publish" command itself or the presence of semicolons (;) in your code, which suppress output display.
Try below steps which might helpful to resolve this issue:
  • Make sure that the publish settings are configured to include the output. You can do this by setting the 'showCode' and 'evalCode' options to true. Here's an example of how you might call publish with these options:
opts = struct('format', 'pdf', 'showCode', true, 'evalCode', true);
publish('your_script_name.m', opts);
  • Ensure that your script is not suppressing output with semicolons (;). Outputs that are suppressed in the script won't appear in the published PDF.
  • Refer the following documentation link to know more about "publish": https://www.mathworks.com/help/matlab/ref/publish.html
If you are getting infinite loops of figures, at the beginning of your script to ensure that all figures are closed before running the script. This can prevent the accumulation of figures.
I hope this helps!

Community Treasure Hunt

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

Start Hunting!

Translated by