.m file (included into .exe) to string

조회 수: 5 (최근 30일)
Yuval Weissler
Yuval Weissler 2016년 1월 7일
댓글: Harsheel 2016년 1월 10일
Suppose I have a main function, which I will compile using mcc, and suppose I have a helper function, which I will include into the compilation, using the '-a' argument.
I want to extract the helper function's code as a string, from the main function exe. The helper function must be included in - no extracting from a separate .m file.
Pre-compilation, I was able to extract the code using importdata(), or fileread(), but after compilation it doesn't work properly.
I tried a few other methods, but nothing worked for me. Any suggestions? Thanks!
  댓글 수: 5
jgg
jgg 2016년 1월 10일
I'm going to post this as a solution, so you can accept it and people can see how you solved the problem.
Harsheel
Harsheel 2016년 1월 10일
sounds good Yuval :)

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

답변 (1개)

jgg
jgg 2016년 1월 10일
This ended up being the solution, although it was posted as a comment: I'm not an expert on mcc, but I don't think that's possible. You can certainly read in the uncompiled .m file, but post-compilation, that shouldn't be possible.
You could try a work-around:
  • Save the file as a .txt file instead of a .m file
  • -a in the .txt file
  • Read in the data from the text file instead
You'll have an extra document floating around but it will be compiled into your compiled code so probably not an issue?

카테고리

Help CenterFile Exchange에서 C Shared Library Integration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by