필터 지우기
필터 지우기

Pass input arugments in .exe file generated by Matlab coder

조회 수: 8 (최근 30일)
Wladimir Plotnikov
Wladimir Plotnikov 2023년 9월 11일
댓글: dpb 2023년 9월 21일
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

채택된 답변

dpb
dpb 2023년 9월 11일
<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
Wladimir Plotnikov
Wladimir Plotnikov 2023년 9월 21일
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 2023년 9월 21일
Kewl...glad it all worked out for you.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Coder에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by