windows and mac differences in basic functionality readtable

Hi,
I have a gui that runs perfectly fine on a Mac with 2017a, when I run it on win2017a (prior to compiling it) I get numerous errors. This one however I do not understand at all
Undefined operator '>' for input arguments of type 'cell'
I can trace it back to the line which reads in the data...
data=readtable(files(k).name,'FileType','text','Delimiter','tab','TreatAsEmpty',['UND. -60001','UND. -2011','UND. -62011']);
the Mac and Windows versions run this differently, the Mac honors the TreatAsEmpty, note on the Mac it requires double quotes (" ") around each argument to exclude as empty whereas the Windows version called that an error and wanted single quotes, it then does nothing with them. This leads to the array being a table in the Mac version of the GUI and a cell in the Windows version, I just can't see why some fundamental matlab basics would be so different between the versions?
Any ideas?
Best regards
Steve
close all
clear all
clc
AA=uigetdir('\\company.com\data\users\ProfileFolders\my.name\Desktop\');
A1=string(AA)
Folder_strings=char(strcat(A1,'/*.txt'))
Folder_used=dir(Folder_strings)
files=Folder_used
nFiles=numel(files)
nameHead=(files(1).name)
expressionA = 'P\H\d\d\d\_'
nameOfHead= regexp(nameHead,expressionA,'match')
nameOfHead=nameOfHead{:}
nameOfHead=(nameOfHead(1,1:5))
for k=1:nFiles
data=readtable(files(k).name,'FileType','text','Delimiter','tab','TreatAsEmpty',['UND. -60001','UND. -2011','UND. -62011']);
name3D=(files(k).name);
RN=name3D;
expression1 = 'M\d\R\d\_';
Z(k)= regexp(RN,expression1,'match');
%%Assign variables to data
vel_NS=data.Velocity_ms;%-NS.....Nozze Scan data
% vol_NS=data.Volume_pl;
% traj_NS=data.Trajectory_deg;
% noz_NS=data.ExpID;
vel_NS(vel_NS > 10)=NaN;%for awful data exceeding 10m/s this will remove them
end

댓글 수: 5

Hi Steve,
It's hard to know what's happening without seeing the file.
First,
I would look at the encoding, Windows and Mac have different defaults. Set 'FileEncoding' in readtable to make that fixed.
Second,
'TreatAsEmpty',['UND. -60001','UND. -2011','UND. -62011']
I think this might not be doing what you want. This is not an array of strings, but a single character vector. (although this behavior is the same on all platforms so I doubt it's contributing to what you're seeing.)
I believe what you want is a cell array containing each character vector you want to be treated as empty:
'TreatAsEmpty',{'UND. -60001','UND. -2011','UND. -62011'}
Unless you really want the single value 'UND. -60001UND. -2011UND. -62011' to be treated as empty.
Finally,
the file separators for Mac and Windows are different.
\\xaar.com\data\users\ProfileFolders\Stephen.Devlin\Desktop\ is using the Windows separator '\'. That can cause confusing errors.
Hope this helps,
Jeremy
Hi Jeremy,
Would it be possible for you to post this as an answer? I had already fixed it but you have nailed the problems I had and I would be more than happy to accept this.
Thank you,
Steve
But take out the pathname part...
Where you used "" as the delimiter, you used a facility available in R2017a and later; your other system must be running an earlier version.
Hi Walter, if you want to move this to an answer field I will accept it, apologies for not getting back sooner.

댓글을 달려면 로그인하십시오.

 채택된 답변

Walter Roberson
Walter Roberson 2018년 6월 7일

0 개 추천

Where you used "" as the delimiter, you used a facility available in R2017a and later; your other system must be running an earlier version.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by