Pass function as an argument to standalone application.

6 vues (au cours des 30 derniers jours)
Piotr
Piotr le 14 Avr 2014
Réponse apportée : Roja le 26 Juin 2014
Hello guys!
I am very new to matlab so please be understanding:) I work on Linux.
I have a function called testwindow that as an argument requires another function stored in another m-file (configuration file).
I need to make it work as a standalone application (to be able to run on a computer without Matlab installed just MCR - Matlab Compile Runtime). So I installed MCR and used Matlab compiler to packed it into a standalone application:
mcc -m -v -w enable -R -startmsg -R -completemsg testwindow.m
And everything went ok, but when I try to run it and pass the "config" function (below) as argument I receive an error:
piotr@sapphira:~/mlvessel-1.4/src/tests$ ./testwindow driveconfig
Initializing MATLAB Compiler Runtime version 8.1
Attempt to reference field of non-structure array.
Error in testwindow (line 30)
MATLAB:nonStrucReference
When working with scripts not standalone app it works ok. So what I am doing wrong?
testWindow.m and driveConfig are attached the problem seems to be following lines in testWindow:
if (~config.window)
return;
end
Many Thanks for any help!

Réponses (1)

Roja
Roja le 26 Juin 2014
The Executable does not accept the function name as an argument but you can try creating a “main” function where you need to store the output of the “driveconfig” function in a parameter “config” and then pass it to the “testwindow” function.
The “main” function:
function main ()
config=driveconfig;
testwindow(config);
end
Use the following command while compiling the “main” function:
>>mcc mv main.m a testwindow.m a driveconfig.m

Catégories

En savoir plus sur Standalone Applications 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