Consistently hide code when mlx file is opened
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Sugandhi
el 9 de Jun. de 2023
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 comentarios
Ver también
Categorías
Más información sobre Environment and Settings en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!