필터 지우기
필터 지우기

Consistently hide code when mlx file is opened

조회 수: 8 (최근 30일)
Febo Cincotti
Febo Cincotti 2023년 5월 27일
답변: Sugandhi 2023년 6월 9일
I would like to distribyte my live script files so that they consistently open in "hide code" mode, by default.
It seems that selecting my view mode to "hide code" and then saving the file (after some arbitrary modification) does not yield the desired behavior.
Any suggestion on how to ensure that users will not see the code, unless they won't to?
Thanks in advance for any hints.

답변 (1개)

Sugandhi
Sugandhi 2023년 6월 9일
Hi,
I understand that you want to share live script files that are in 'hide code' mode.
One possible workaround is to insert blank text in any of the code section and set view of the file to 'hide code', run the code and save the file. On opening again, code will still remain hidden.
Other possible workround you can look in to is generate view of MATLAB file in specified format, use publish function in MATLAB.
publish(file) generates a view of the specified MATLAB code file and output in an HTML format that can be used for sharing. publish saves the HTML file and a file for each graphic that the code creates in a subfolder named html. The location of the html subfolder is relative to the location of file.
For example, publish('C:\myMATLABfiles\myfile.m') runs the code in myfile.m using the base workspace, and then saves the formatted code and results in C:\myMATLABfiles\html\myfile.html.
publish(file,options) uses the options structure to generate the view of the specified MATLAB file. Using a structure to specify options is useful when you want to preconfigure and save your options for repeated use. The fields and values of the options structure correspond to names and values of name-value pair arguments. A Example is given below.
Create a structure options that specifies the format and showcode options.
options.format = 'doc';
options.showCode = false;
Use the publish function to generate a Microsoft Word view of the example using the options specified in options. Then, use the winopen function to view the resulting file.
publish('fourier_demo2.m',options);
winopen('html/fourier_demo2.doc')
I work at MathWorks, and the relevant people are aware of the issue with 'hide code' feature.
For more information, please go through the following link:

카테고리

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

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by