Filter löschen
Filter löschen

standalone executable and write to a txt file

59 Ansichten (letzte 30 Tage)
Márcio Marques
Márcio Marques am 6 Jun. 2017
Kommentiert: Elijah am 16 Jul. 2024 um 15:44
Hi everybody,
I have one program that runs perfectly in matlab. The program when receive one input, write in report.txt.
With standalone Executable i maked a exe. but when i running the exe, and give a input of program, the program doesn't write to the report.txt.
Anyone knows how to solve this problem?
Thank you in advance.
  3 Kommentare
Elijah
Elijah am 15 Jul. 2024 um 15:39
Bearbeitet: Elijah am 15 Jul. 2024 um 15:41
I am having the same issue. I created a very simple program to test. It opens a new file and writes to that new file. When trying to convert to the executable through the Matlab Coder, I first have to create a C file. During that proccess, it works, but when converting to the excutable with the additional C file, the executable does not work. I am able to change to C file to include printf and It is able to use printf to display in the Matlab's command window, and the function returns 0, which is the default when it is done running code.
function Test_Write()
device = fopen('any location',"w+"); % insert location
fwrite(device_write, 'This Works', "char")
end
With the code above, I follow the steps on this page. And after removing 'This Works' from the C file test, nothing is printed on the file when the executable is run.
Elijah
Elijah am 16 Jul. 2024 um 15:44
I was able to get it working with this code. It will create a folder with the executable inside. To call it use system. The name does not have to have .exe at the end. For some reason I cannot get Matlab Coder to work.
buildResults = compiler.build.standaloneApplication('your_file.m')
system('your_file.exe')

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by