How can someone run my code without having all required toolboxes?

I'd like to send my matlab code to someone for evaluation. I converted the bulk of my code to .p code as I don't want to reveal their content. There is a small script in .m format that can be modified by the user and which calls the .p file. Now the person I sent this to says that he doesn't have all the required toolboxes. How can I package it so he can still run it?
I first thought of using Matlab compiler to compile the code currently in the .p file. However, it appears to create an exe file or windows library. Those cannot be called by my .m script. At least I don't know how to do that. The other option I considered was to use Matlab coder to generate a .mex file. However, this is taking a lot of effort as various functions are not supported for code generation and various other errors are cropping up related to conversion to C.
So the 2 choices I've tried are 1) Compiler easily creates a .exe file but how do I call it from the .m script and 2) Coder takes a lot of work to convert to C but the resulting .mex file will be easy to call from the .m script
Is there some solution that combines the advantages of both? Thanks!

Antworten (1)

Walter Roberson
Walter Roberson am 27 Feb. 2017
Bearbeitet: Walter Roberson am 27 Feb. 2017
MATLAB Compiler SDK can generate dll or .mex* files that can be called from MATLAB.
However, I do not know how licensing works for toolboxes for that situation.
MATLAB Compiler can be used to create an exe that you can invoke using system(). You could write it to take string command line arguments, and you can capture the return output as strings. For binary you could have the invocation name an output file and the invoking code could read the file. For example it might be reasonable to save() the output into a .mat and then load() the .mat in the invoking script. It might also be reasonable to save the parameters into the .mat before the file. For example,
workfile = [tempname() '.mat'];
params.timestep = 1e-9;
params.order = 7;
save(workfile, '-struct', 'params');
[status, result] = system( sprintf('YourExe.exe "%s"', workfile) );
if status ~= 0
error('Failed to execute because: %s', result);
end
params = load(workfile);
if ~isfield(params, 'YesItWorked')
error('That''s odd, the program did not complete');
end
surf(params.X, params.Y, params.Z, 'edgecolor', 'none')

2 Kommentare

Thanks a lot. How do I create a mex file using Compiler SDK? I only see examples for creating dll files.
Compiled mex files are dll.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu MATLAB Compiler finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 27 Feb. 2017

Kommentiert:

am 27 Feb. 2017

Community Treasure Hunt

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

Start Hunting!

Translated by