필터 지우기
필터 지우기

standalone executable and write to a txt file

조회 수: 59 (최근 30일)
Márcio Marques
Márcio Marques 2017년 6월 6일
댓글: Elijah 2024년 7월 16일 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
Elijah
Elijah 2024년 7월 15일 15:39
편집: Elijah 2024년 7월 15일 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 2024년 7월 16일 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')

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by