Why does the 'publish' code turn my program into a recursive one and NOT publish?

조회 수: 2 (최근 30일)
I've added
options_pdf_nocode.format = 'pdf';
options_pdf_nocode.showCode = false;
publish('clinicalreport.m',options_pdf_nocode);
to the bottom of my code but instead I'm having my code run recursively with no published output. Why?

채택된 답변

Walter Roberson
Walter Roberson 2014년 3월 20일
publish(file) generates a view of a MATLAB® file in HTML format for sharing your code. For example, publish('myfile.m') executes the code in myfile.m using the base workspace and saves the formatted code and results in /html/myfile.html. The html subfolder is relative to the file folder.
Notice the "executes the code in myfile.m". Your program clinicalreport.m is attempting to call publish within itself. So the call to publish attempts to execute clinicalreport. That run gets to the publish() call which then attempts to execute clinicalreport. That run gets to the publish call... and on and on it goes calling itself until the stack is blown. At which point it errors out of the entire call tree without having finished writing the result of the 499 executions of clinicalreport.m
You are going to continue to have this problem as long as you have a program trying to publish itself, unless you put in specific mechanisms to ensure that the execution due to the publish() run does not trigger another call to publish()
  댓글 수: 1
Golnar
Golnar 2014년 3월 20일
편집: Golnar 2014년 3월 20일
Walter, is this
copyfile(fullfile(matlabroot,'help','techdoc',...
'matlab_env','examples','fourier_demo2.m'),'.','f')
the key ? If I write this in before those three lines, will it work? If so, I don't know exactly how to use this line. What is 'matlabroot', etc? and the '.', and 'f'?

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Report Generator에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by