Consistently hide code when mlx file is opened
16 ビュー (過去 30 日間)
古いコメントを表示
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.
0 件のコメント
回答 (1 件)
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:
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で File Operations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!