How can I compile a live script exporter?

조회 수: 9 (최근 30일)
Ben Brust
Ben Brust 2022년 1월 7일
답변: Martin Knelleken 2022년 1월 27일
I have created a live script export function with the help of this answer and I want to compile it into an executable.
It compiles into an exe, but when trying to execute I receive an error. I imagine it occurs because I am calling an internal function.
Is there a way I can get around this limitation?
The intention for this is to allow other applications such as Git view a text representation of live scripts.
Here's the very simple function which works well from MATLAB:
function mlxToLaTeX(mlxFilePath)
% Description:
% Function to convert a *.mlx file to LaTeX format text and display in
% the command window.
%
% Compile by running:
% mcc('-m', '-d', pwd, 'mlxToLaTeX.m');
%
% *************************************************************************
% Examples:
% mlxToLaTeX('someScript.mlx');
%
% See also matlab.internal.liveeditor.openAndConvert
tmpFile = sprintf('%s.tex', tempname);
matlab.internal.liveeditor.openAndConvert(mlxFilePath, tmpFile);
texCode = fileread(tmpFile);
delete(tmpFile);
fprintf('%s',texCode);
But when compiled, I recieve the following output:
!mlxToLaTeX someScript.mlx
Unable to resolve the name matlab.internal.liveeditor.openAndConvert.
Error in mlxToLaTeX (line 31)
MATLAB:undefinedVarOrClass
MATLAB version: 2019b
Thank you,
Ben

채택된 답변

Martin Knelleken
Martin Knelleken 2022년 1월 27일
Hi Ben,
Thank you for using the Live Editor and for bringing this up!
Indeed, matlab.internal.liveeditor.openAndConvert is not supported by the MATLAB complier. You should have seen warnings while running the compiler already. Something like: 'The file or function has been excluded from packaging for the "MCR" target environment'. One reason is that this is an internal function which is not made for public use and therefore it's not neccessarily supposed to work with the compiler.
We're actively working on a public replacement for openAndConvert. I can't promise that the first version of that will be fully supported by the compiler but we'll definitively attach importance to that.
Thanks
- Martin

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Source Control Integration에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by