MATLAB: Matlab importdata() function fails over remote session

importdataimporting excel datapowershellremote sessionssh

Hi,
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: ');
disp(myData)
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.
Thanks!

Best Answer

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.
Related Question