Allowing user provided .m functions in compiled GUI

6 vues (au cours des 30 derniers jours)
SAM
SAM le 15 Jan 2015
Modifié(e) : SAM le 15 Jan 2015
Hi,
I have tried to read many documentations on compiled Matlab GUI but was unable to find an answer to my question.
I want to create a compiled GUI in 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).
.m is some simple function 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
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',...
'Position',[320 10 150 25],...
'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 is not good 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

Réponses (0)

Catégories

En savoir plus sur Search Path dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by