Using xlsread with the MATLAB Engine

2 ビュー (過去 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 Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by