Matlab Coder with Command Line Parameters
이전 댓글 표시
I have completed the coderand example. My next step is to create an executable that accepts command line inputs.
Here is my MATLAB code:
function c = Calculator(whichcalc) %#codegen
fprintf('%s\n',whichcalc);
if whichcalc=="pressure"
c = "Your calc is the pressure calculator";
elseif whichcalc=="temperature"
c = "Your calc is the temperature calculator";
else
c = "No idea which calculator.";
end
fprintf('%s\n',c);
end
And the associated command to run the application:

I've created the C++ source code using Matlab coder & then used Visual Studio to compile the code using a local ubuntu vm.
Where have I gone wrong?
댓글 수: 2
Ryan Livingston
2019년 2월 13일
Can you share the C++ main function that you're using? The generated code doesn't read from the command line, so your main function needs to take argv and forward that to the generated entry-point function.
Here's an example that shows taking arguments in the main function and passing them to the generated code:
https://www.mathworks.com/help/coder/ug/generate-and-modify-an-example-cc-main-function.html#buod55s
Specifically look at main in main.c that reads from argv.
Kristen Lancaster
2019년 2월 13일
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 MATLAB Coder에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
