Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Stand alone excutables runs ok in the directory it was mcced but not in another directory

1 回表示 (過去 30 日間)
Tianyou Chen
Tianyou Chen 2013 年 4 月 2 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hi All,
I am trying to build an standalone exe from a very simple function. I had problems with the paths before so I included the called functions in the main function. Then mcc -mv myfunction.m. the myfunction.exe runs fine when in the same directory it was created. However, it does not work properly when copied to and run from another dirfectory of the same computer. It seems that it fails to call the function (included in myfunction.m) which returns a structure. So when the trying to reference to the field of the returned structire it gives an error and quits. It does not make much sense - sucha simple task. I wonder what is wrong. By the way I am using R2012b.
Any suggestions?
Thanks and cheers, Tianyou

回答 (1 件)

Walter Roberson
Walter Roberson 2013 年 4 月 2 日
How are you referencing the called function? If you name it in a string only, then use
%#function FUNCTIONNAMEHERE
to force it to be included
For example, if you had
eval('loadit myfile')
then add
%#function loadit
to your routine.
  1 件のコメント
Tianyou Chen
Tianyou Chen 2013 年 4 月 2 日
Hi Walter,
Thank you for the help. I called the function directly. The main function is like this
---------------------
function myfun
% call fun1 to get a structure S
S = fun1(x,y);
b = s.name
end
% the definition of the fun1
funcion s= fun1(arg1,arg2)
s.name = 'test';
...
end
-------------
ao all the functions I use is included in the main function.
Thanks and cheers, Tianyou

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by