Problem with publish and plots

조회 수: 31 (최근 30일)
matt
matt 2017년 12월 5일
편집: Richard Quist 2022년 2월 26일
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
Md. Mahmudul Hasan Shihab
Md. Mahmudul Hasan Shihab 2021년 7월 2일
Use this format in the command window.
options.format = 'pdf';
options.showCode = true; % if you want to hide the code write "false"
publish('file_name',options);

댓글을 달려면 로그인하십시오.

답변 (1개)

Richard Quist
Richard Quist 2022년 2월 26일
편집: Richard Quist 2022년 2월 26일
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
bar(magic(4));
% publish it
publish('foo.m', 'pdf')
Instead, remove the call to publish from your script:
% myscript.m
% create a plot
bar(magic(4));
... and place the call to publish in a separate script or call it from the MATLAB command window:
% publish myscript
publish('myscript.m', 'pdf')

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by