Matlab engine - C++ doesn't call matlab function written by myself

조회 수: 2 (최근 30일)
Ruiqi Zhao
Ruiqi Zhao 2013년 12월 27일
댓글: Ruiqi Zhao 2013년 12월 30일
I try to call a matlab function in C++. The matlab function is written by myself. But it seems that C++ doesn't call this function at all. I have successfully run "engwindemo.c". I also do a modification to "engwindemo.c" to make it call a simple function written by myself. It also doesn't work. I am thinking that maybe the function is not put in the right folder. What's the path that I should put my matlab function? Or are there other causes? Thanks for help!

채택된 답변

James Tursa
James Tursa 2013년 12월 27일
편집: James Tursa 2013년 12월 27일
The Engine starts up with the default folder, so if your function is not on the path at start up then the Engine will not see it. You will need to send some "cd" or "path" commands to the Engine first to make the function visible (or maybe have these in a startup.m file that the Engine executes).
  댓글 수: 5
Ruiqi Zhao
Ruiqi Zhao 2013년 12월 28일
The function [FreCnt, UniqE, leg] = Search(info, query, thresh) is my matlab function. info is a struct with two fields, query is double vector, thresh is a double number. I checked that the inputs are read well. But still there is no return for the outputs. The matlab function also works well in matlab command. Thanks.
Ruiqi Zhao
Ruiqi Zhao 2013년 12월 30일
Hi James, after trial and error, I still couldn't figure out what's wrong with my code, then I gave up matlab engine and used matlab Compiler to create C++ shared libraries instead. It worked perfectly. I only did a small modification on my matlab engine code. So don't bother to examine the code for me any more.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Call MATLAB from C에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by