필터 지우기
필터 지우기

Using xlsread with the MATLAB Engine

조회 수: 1 (최근 30일)
Caroline
Caroline 2013년 7월 22일
I am trying to use the xlsread function in matlab through the MATLAB engine. I was trying to use engEvalString() to implement it, however it is returning 0 every time that I try to implement it so I don't think that I am using engEvalString() correctly. Right now this is how I am trying to implement it:
engEvalString(ep, "[num, text, raw] = xlsread(\"C:\\Users\\rest_of_filename_path\")")
Any feedback that anyone could provide would be great, Thanks!

채택된 답변

James Tursa
James Tursa 2013년 7월 22일
Please explain "returning 0". Is the engEvalString call itself returning 0? If so, that is good because that is the normal state. Are you really using double quotes inside your eval string? I would have thought single quotes would be required. E.g., something like this:
engEvalString(ep, "[num, text, raw] = xlsread('C:\\Users\\rest_of_filename_path\')")
Then use engGetVariable to get num, text, and raw.
  댓글 수: 3
James Tursa
James Tursa 2013년 7월 22일
편집: James Tursa 2013년 7월 22일
Try this:
- Open the Engine
- Use engEvalString to do the xlsread stuff
- Pause or close your program, but DO NOT use engClose in your program ... i.e. leave the Engine running.
- Manually click on the Engine window and then see what is in the workspace (i.e. see if there are num, text, and raw variables there with the expected values). I.e., use the whos command etc to examine the workspace.
If the num, text, and raw variables are there with the expected values then the problem is with your engGetVariable code. If the variables are not in the workspace then the problem is with your xlsread and you will have to debug that.
In your engGetVariable code, aren't you assigning the results to variables? If so, you don't show it. E.g., something like this is what I would have expected:
mxArray *num, *text, *raw;
:
num = engGetVariable(ep, "num");
text = engGetVariable(ep, "text");
raw = engGetVariable (ep, "raw");
Caroline
Caroline 2013년 7월 24일
Thank you!

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

추가 답변 (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