Why no output from standalone application when run in Windows?

조회 수: 8 (최근 30일)
KAE
KAE 2024년 3월 6일
편집: KAE 2024년 3월 7일
How can I see the output from a standalone application compiled from Matlab, when I run the application in Windows?
Here's what I tried, but no output is shown. First, the mfile,
function [numOutput1, numOutput2, strOutput1, strOutput2] = test_compiled1(numInput1, numInput2, strInput1, strInput2)
% Convert inputs to numeric
if isstr(numInput1)
numInput1 = str2double(numInput1);
end
if isstr(numInput2)
numInput2 = str2double(numInput2);
end
% Do something with inputs and outputs
numOutput1 = numInput1.^numInput2;
numOutput2 = numInput1 - numInput2;
strOutput1 = [strInput1 '_' strInput2];
strOutput2 = [strInput2 '_' strInput1];
%% Return the output by displaying the results
disp([num2str(numOutput1) ' ' num2str(numOutput2) ' ' strOutput1 ' ' strOutput2 ])
When I run it in Matlab, it displays the output,
test_compiled1(2, 3, 'a', 'b')
8 -1 a_b b_a
Then I compile it as follows,
fileMatlab = 'test_compiled1.m';
buildResults = compiler.build.standaloneApplication(fileMatlab);
compiler.package.installer(buildResults);
In Windows, I navigate to the directory that test_compiled1.exe is in, and run it as follows,
.\test_compiled1.exe 2 3 "a" "b"
Nothing is displayed and it takes ~30 seconds to run. Putting a and b in single quotes or no quotes at all doesn't change this. And if I pipe the output to a log file and an error file, both are empty.
.\test_compiled1.exe 2 3 "a" "b" >output.log 2>error.log
How can I see the output of this standalone application from Windows?

채택된 답변

KAE
KAE 2024년 3월 7일
편집: KAE 2024년 3월 7일
The solution had nothing to do with the code. I had multiple copies of test_compiled1.exe in different directories. When I deleted them all, compiled as shown above, then ran it from the Windows command line, it successfully displayed the output or piped it to a log file, though it does take 11 seconds to run and only 1 s when I run the mfile in Matlab.
I won't delete this question in case it helps someone who needs a simple example.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Compiler에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by