"I have read that xlsread does not work on Mac and I would like to know if someone could explain why and if there are work arounds."
This is not exactly true. xlsread works on a Mac if use the 'basic' option (which is on by default on Macs I believe). With the 'basic' option xlsread parses the excel file directly instead of communicating with excel to extract the data. However, with sufficiently complex excel files, xlsread may not parse the file correctly.
Even if you can use xlsread on a mac, you're still better off using readtable, readmatrix, and co. They're improvement over xlsread. By default in R2020a, readtable parses the excel file directly and works on a Mac. Just like with xlsread, there may be instances where this process fails but in general it shouldn't.
If you want to know the nitty-gritty, xlsread when not in basic mode, and readtable when 'UseExcel' is true, start Excel, ask Excel to open the file, then ask excel for the content of the spreadsheet it has read. This guarantees that the file is read correctly since it's excel doing it but the communication with excel is is only possible on Windows since the mechanism it uses (called COM or ActiveX) is only available on Windows. It would require cooperation between Apple and Microsoft to be implemented on Macs, I wouldn't hold my breath...
"I have tried readtable but it stores the dates in numbers"
That shouldn't be the case but if it happens you should be able to convert the numbers back to date using the 'ConvertFrom', 'excel' option of datetime.
"it gives me errors when trying to convert these into arrays"
You've done something wrong then. Without details of what you're doing nor the text of the error message, it's hard to help you.
" I have also tried converting the excel into CSV but that seems to work. I also get errors whe trying to apply MATLAB functions like yearfrac and datenum on manually imported data."
Again, not enough details about what you're doing or the errors.
"Is there any way to circumvent a manual import or installing a windows virtual machine?"
Use readtable, readmatrix, or readcell. In your case, I'd use readcell to read the whole spreadsheet in then read the required data out of the cell array. Note that the design of your spreadsheet is great for a human reader, but really not ideal for processing by a program.
allcontent = readcell(filename);
dates.settlement = allcontent{8, 5};
dates.depos = cell2mat(allcontent(11:18, 4));
dates.futures = cell2mat(allcontent(12:20, 17:18));
2 Comments
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/521724-how-to-import-excel-data-in-matlab-in-mac#comment_837812
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/521724-how-to-import-excel-data-in-matlab-in-mac#comment_837812
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/521724-how-to-import-excel-data-in-matlab-in-mac#comment_837824
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/521724-how-to-import-excel-data-in-matlab-in-mac#comment_837824
Sign in to comment.