How can I make correct executable file?
信息
此问题已关闭。 请重新打开它进行编辑或回答。
显示 更早的评论
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!
0 个评论
回答(1 个)
Steven Lord
2018-6-25
0 个投票
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.
0 个评论
此问题已关闭。
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!