How to publish as pdf from command tab

조회 수: 18 (최근 30일)
Struggling in MATLAB
Struggling in MATLAB 2022년 4월 22일
댓글: Sean de Wolski 2022년 4월 25일
I have a function which I am running from command window as follows.
[logical_out, run_time, reaction_time] = reaction_time_function4('alexis', '11-Feb-2022', 'Trial27')
But when I try to save the result as pdf in the command window using
publish('reaction_time_function4.m','pdf');
it throws me an error.
data_on_date = sorted_data(sorted_data.date == char(day),:);
Basically I have to hard code the function which I want to avoid. (Because it will be more time consuming)
When I try to add the publish command in the function it throws me the same error.
Is there any work around this?

채택된 답변

Steven Lord
Steven Lord 2022년 4월 22일
To do this using the publish function use the codeToEvaluate name-value pair argument as shown in the "Generate HTML View of MATLAB function with Input Arguments" example on the publish documentation page.
  댓글 수: 1
Struggling in MATLAB
Struggling in MATLAB 2022년 4월 23일
편집: Struggling in MATLAB 2022년 4월 23일
Thanks for your comment! I almost got what I needed. Although the following code worked, but I am getting too many outputs.
publish('reaction_time_function4.m','codeToEvaluate','[logical_out, run_time, reaction_time] = reaction_time_function4(''alexis'', ''11-Feb-2022'', ''Trial27'');')
I want in pdf format and only 1 .pdf output. How can I do that?

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

추가 답변 (1개)

Sean de Wolski
Sean de Wolski 2022년 4월 22일
Open the function and go to the publish tab in the toolstrip. From there, click the dropdown under the publish icon for settings. Change the function call in the "MATLAB Expression:" to be: [logical_out, run_time, reaction_time] = reaction_time_function4('alexis', '11-Feb-2022', 'Trial27')
Then hit publish.
  댓글 수: 2
Struggling in MATLAB
Struggling in MATLAB 2022년 4월 22일
Thanks for your comment. But I don't see a 'settings option' under publish dropdown.
By function call in the "MATLAB Expression:" do you mean running command from command window like the image?
Sean de Wolski
Sean de Wolski 2022년 4월 25일
Sorry, it's "Options" not settings, the second item in the dropdown. You can also select "PDF" as the output format in there.

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

카테고리

Help CenterFile Exchange에서 Debugging and Analysis에 대해 자세히 알아보기

태그

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by