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!
