Matlab Coder with Command Line Parameters
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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:
![screenshot.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/202697/screenshot.png)
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 Commenti
Ryan Livingston
il 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.
Risposte (0)
Vedere anche
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!