Reputation: 13
I have tried to read many documentations (especially http://blogs.mathworks.com/loren/2008/08/11/path-management-in-deployed-applications/ where the question is asked but not answered to) on compiled Matlab GUI but was unable to find an answer to my question.
I want to create a compiled GUI in Matlab (compiled with deploytool and that can run on a computer that does not have Matlab), where at some point, the user can specify his own matlab .m file (say for example : myProfile.m) and the Gui uses it later on (this last point is the tricky part).
myProfile.m is some simple function (it takes one argument and outputs one value) that can be located wherever the user wants, and that is totally user defined. I give here a simple example:
function [y] = myProfile(x)
y = x^2;
end
but it can be more complex.
In the Gui I ask the user the path to his profile function and I try to make it a function handle :
Button1 = uicontrol('String','Browse path to your Profile',...
'Position',[320 10 150 150],...
'Callback',@button1_Callback);
function [profileFunc] = button1_Callback(varargin)
[ProfileName,ProfilePath] = uigetfile({'*.m'},'Select your profile');
addpath(ProfilePath);
profileFunc = str2func(strcat('@',ProfileName));
% profileFunc will be used later on in the code
end
Of course, after compilation this code doesn't work, and I get the following error:
'C:\Users\...\myProfile.m' is not in the application's expanded CTF archives at
'C:\Users\...\mcrCache8.0\myGui'. This is typically caused by calls to ADDPATH ...
I know that using addpath in a Gui does not work when you compile the Gui. But if I don't add the path, the program can not find the user provided myProfile.m . So how can I solve this?
Thanks,
Sam
Upvotes: 1
Views: 292
Reputation: 36720
When viewing this from a licensing point it is very simple. Mathworks can not allow to deploy such code, you could easily deploy your own command line version of matlab which runs arbitriray code and does not require any license.
In my opinion there is only one way to go: Deploy m-code and ask the user to install matlab or octave.
Alternative: If you deploy a jar, the JRE is already running. Concider using java script as the JRE already brings the script engine. Then the user would have to input java script.
Upvotes: 1