Matlab Coder with Command Line Parameters
6 views (last 30 days)
Show older comments
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 Comments
Ryan Livingston
on 13 Feb 2019
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.
Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!