How can I make correct executable file?
Infos
Cette question est clôturée. Rouvrir pour modifier ou répondre.
Afficher commentaires plus anciens
I made an executable file from my code below.
mcc -m test_yli.m
My code:
#
function b = test_yli(a)
if ischar(a)
a = str2num(a);
end
b=a+1;
disp(b)
disp('code stop here')
Then I run
#
[status result] = system('"test_yli.exe" "1"')
But the returned value are
status =
0
result =
2
code stop here
But I simply want to get the returned b=2. If I delete the two disp() command in my -m code for making the executable file, then my returned value (e.g. retult) is empty!
status =
0
result =
''
Can anyone please tell me where I'm wrong? Many thanks in advance!
Réponses (1)
Steven Lord
le 25 Juin 2018
0 votes
From the "Using a MATLAB File You Plan to Deploy" section on this documentation page: "You cannot return values from your standalone application to the user. The only way to return values from compiled code is to either display it on the screen or store it in a file."
Remember, MATLAB isn't running your application. Your operating system is, and your operating system has no notion of how a MATLAB variable should be stored in memory if it were to be returned from your application.
Cette question est clôturée.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!