How to call a .mexw64 file in a .m function? / MEX workflow

Hi there,
I have built a MEX-compatible .c file, compiled it with a suitable compiler, tested it, and generated a .mexw64 file.
I would like to call the MEX function from a .m function, so I tentatively add the path .../project/mex/ ; this is where the .mexw64 file has been placed.
I call the mex file from a .m function which resides at .../project/m/ simply by the filename, as if it were an internal funtion e.g.
chk = calcChecksum(line);
I'm curious about the following:
1) Does this seem like a reasonable approach?
2) Must I do anything to setup the ability to call MEX functions prior to the call?
3) When one does the typical
mex -setup
<choose compiler>
mex '...\project\c\calcChecksum.c'
where is the .mexw64 (or equivalent) file written?
Thanks,
Chris

 채택된 답변

Kaustubha Govind
Kaustubha Govind 2012년 10월 10일
편집: Kaustubha Govind 2012년 10월 10일

1 개 추천

  1. Yes, this is the correct approach.
  2. No, you don't need to set anything up, other than adding the directory containing the .mexw64 file to the MATLAB path.
  3. Typically the MEX binary gets generated into the directory that you run the MEX command from (unless you use the "-outdir dirname" option with the mex command).

댓글 수: 5

James Tursa
James Tursa 2012년 10월 10일
편집: James Tursa 2012년 10월 10일
Not part of OP's question, but I would add for completeness of the thread:
4. Have a calcChecksum.m file in the same directory as your calcChecksum.mexw64 file that contains all of the help documentation and H1 line for the function. That way "help calcChecksum" and "lookfor" will work.
Thanks very much to you both, for the comments. I like the idea about placing the function description of the .mex in a .m in the same directory. Much appreciated.
Great tip, James. Thanks!
Hi! I'm sorry to hijack this thread, but I was wondering what to do if it is the opposite case? Basically if I want a .m file from .mexw64. Thank you!
You should probably start a new Question. Also, not sure what you are asking ... turning a mexw64 file into an m-file (not possible), or using a mexw64 file to call an m-file (is possible).

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 MATLAB Compiler에 대해 자세히 알아보기

제품

질문:

2012년 10월 10일

댓글:

2014년 6월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by