Clear Filters
Clear Filters

Problem with publish and plots

5 views (last 30 days)
matt on 5 Dec 2017
Edited: Richard Quist on 26 Feb 2022
I am trying to publish my code to a pdf (publish('file','pdf'), but when i run my script it gets caught in an infinite loop creating the plots repeatedly. The code works fine without the publish function at the end, only when I try to use it does it give me problems.
  1 Comment
Md. Mahmudul Hasan Shihab
Use this format in the command window.
options.format = 'pdf';
options.showCode = true; % if you want to hide the code write "false"

Sign in to comment.

Answers (1)

Richard Quist
Richard Quist on 26 Feb 2022
Edited: Richard Quist on 26 Feb 2022
If your code looks like the following then you are recursively invoking your script (you call your script, which calls the publish command, which calls your script, which calls publish, ...)
% myscript.m
% create a plot
% publish it
publish('foo.m', 'pdf')
Instead, remove the call to publish from your script:
% myscript.m
% create a plot
... and place the call to publish in a separate script or call it from the MATLAB command window:
% publish myscript
publish('myscript.m', 'pdf')


Find more on Graphics Object Identification 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!