Matlab importdata() function fails over remote session

48 views (last 30 days)
J G on 26 May 2020
Commented: Wayne on 6 Jun 2022 at 19:35
I am attempting to use the Matlab importdata() function in a script which I run over a remote session on a VM. My script imports data (a list of numbers) from an excel spreadsheet into a variable. The script works perfectly when I am logged into the VM via Windows 10 RDC, but fails when I am logged in via Powershell (PS-Session) or Windows 10 SSH.
Other Matlab scripts that I have run remotely in this manner have executed fine. I have only noticed this behavior with the importdata() function.
Here are the contents of my test script (testImportData.m):
disp('Lets try importing the data!');
myData = importdata('test.xlsx');
disp('The data is: ');
This is the command I used to execute the script in my remote Powershell session:
matlab -r testImportData -logfile myLog.txt
This is the output of the log file containing the returned error message:
Lets try importing the data!
[Warning: File contains uninterpretable data.]
[> In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('importdata', 'C:\Program Files\MATLAB\R2019a\toolbox\matlab\iofun\importdata.p', 146)" style="font-weight:bold">importdata</a> (<a href="matlab: opentoline('C:\Program Files\MATLAB\R2019a\toolbox\matlab\iofun\importdata.p',146,0)">line 146</a>)
In <a href="matlab:matlab.internal.language.introspective.errorDocCallback('testImportData', 'C:\Users\myUserName\Documents\testImportData.m', 2)" style="font-weight:bold">testImportData</a> (<a href="matlab: opentoline('C:\Users\myUserName\Documents\testImportData.m',2,0)">line 2</a>)]
The data is:
data: []
textdata: {}
I have attached the relevant files.
  1 Comment
Wayne on 6 Jun 2022 at 19:35
Hello, I have a question, how did you set up your powershell to where you can run Matlab commands from the command line, everytime I just try to call Matlab it does not recognize.

Sign in to comment.

Accepted Answer

J G on 15 Jun 2020
So for those who are interested, based on info I recieved from Mathworks tech support, it seems that this is a known behavior. Importdata cannot access the excel program in a remote session via SSH, or PS-Remote. I think the following posts may be related:
I did try the solutions suggested and adjusted the Excel com settings, but this did not work for me.
My workaround was to use the readcell function instead of importdata, which does work.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!