Using xlsread with the MATLAB Engine

2 vues (au cours des 30 derniers jours)
Caroline
Caroline le 22 Juil 2013
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!

Réponse acceptée

James Tursa
James Tursa le 22 Juil 2013
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 commentaires
James Tursa
James Tursa le 22 Juil 2013
Modifié(e) : James Tursa le 22 Juil 2013
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 le 24 Juil 2013
Thank you!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Startup and Shutdown dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by