Using xlsread with the MATLAB Engine

2 visualizaciones (últimos 30 días)
Caroline
Caroline el 22 de Jul. de 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!

Respuesta aceptada

James Tursa
James Tursa el 22 de Jul. de 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 comentarios
James Tursa
James Tursa el 22 de Jul. de 2013
Editada: James Tursa el 22 de Jul. de 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 el 24 de Jul. de 2013
Thank you!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by