Borrar filtros
Borrar filtros

Pass input arugments in .exe file generated by Matlab coder

4 visualizaciones (últimos 30 días)
Wladimir Plotnikov
Wladimir Plotnikov el 11 de Sept. de 2023
Comentada: dpb el 21 de Sept. de 2023
Hello everybody,
it's the first time I'm working with the Matlab coder.
My aim is to generate an .exe file, where it's possible to pass arguments in order to run the program.
Up to now, I could actually manage to generate an .exe file which runs perfectly.
My issue is to pass arguments in this .exe file, since it's still a static program running every run with the same parameter values.
Assuming my generated file has the name "Test.exe" and one input is the parameter "dim" (so in Matlab it's Test(dim)), I'm running the program with "system('Test.exe dim')".
In order to check the value of the input "dim", I'm using fprintf for the console.
Further on, to enable the generation of the .exe, I've used:
if(isempty(dim)==0)
dim = 1;
end
Unfortunately, it doesn't matter which value dim has, it's always empty "[ ]".
For better illustrations, my example code:
Test(dim)
fprintf("The parameter dim has the value: %1.0f", dim)
if(isempty(dim)==0)
dim = 1;
end
end

Respuesta aceptada

dpb
dpb el 11 de Sept. de 2023
<You must modify a main.c> function to read/use an argument list when creating a standalone executable; it doesn't happen by default (as you've discovered).
Follow the above link in detail, it progresses through the steps of showing how/where the default main.c file is created and then how to modify a copy to include the things your application needs....eventually it gets to illustrating the use of the C command line argument functions to (in the example) read a specific input file instead of using the builtin default image the example starts with.
Follow the bread crumbs trail through the woods and, like Hansel and Gretel, you'll eventually get back from the witch's house to the land of Oz...or is it Kansas?
  9 comentarios
Wladimir Plotnikov
Wladimir Plotnikov el 21 de Sept. de 2023
Hey there,
I just wanted to say that I could manage it to store my relevant data by using fopen and fwrite while creating a .bin file.
Then, I've written a .m file which opens and plot my data from the .bin file.
It perfectly works, thanks a lot for your help!
dpb
dpb el 21 de Sept. de 2023
Kewl...glad it all worked out for you.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre MATLAB Coder en Help Center y File Exchange.

Productos


Versión

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by