Using xlsread with the MATLAB Engine

2 次查看(过去 30 天)
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");

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by