How to read values from excel file with mobile matlab app?

Hi, I want to read values from Excel file with the Matlab mobile app but It seems to do not read correctly! With the same code on PC works fine! What can be the reason? filename = 'Acceleration.xls'; sheet = 'Raw Data'; xlRange = 'D:D'; columnD = xlsread(filename,sheet,xlRange)

9 Comments

As mentioned, it will be better to use the more robust functions - readtable, readmatrix
If there is still a problem or you encounter an error, please specify in detail what the issue is.
Thank you very much! 'readmatrix' works perfectly. If I may ask one more thing? The column I want to read from the Excel file has a title, and the number of data in it is variable. How can I manage to read from the second cell and read all the rest of the data from the column? Thanks in advance!
If you are using readmatrix(), it should automatically read the numbers/numeric data only, discarding the 1st row containing titles/names of column.
Thank you for the reply! Readmatrix read the text title (first cell in the column) as NaN.
readmatrix() will NOT discard the row and column of text. Instead it will insert NaN in place of the data.
I recommend readtable() and accessing the column by variable name.
I overlooked the fact that you provided a range as input.
In that case, one option is to delete the first row.
Other option is to modify the range option, but that requires knowing the last row value of the data. Since this is hardcoding the value, it is a less preferred option in general.
filename = 'Acceleration.xls';
sheet = 'Raw Data';
%Say the last row is 26
xlRange = 'D2:D26';
columnD = readmatrix(filename,sheet,'Range',xlRange)
Ok, thank you very much! I will try! :)
Sorry, I overlooked the range too. readmatrix()
You will probably need
columnD = readmatrix(filename, 'sheet', sheet, 'Range', xlRange)
Yes, and for removing the first elemnt I use: columnDD=columnD(2:end) and it works.

Sign in to comment.

 Accepted Answer

Hi
I understand yow would like to extract values from an Excel file in MATLAB Mobile App.
I would suggest you use alternatives of "xlsread" as it is not recommended by the MATLAB since R2019a. Instead of this, you can try using the "readtable", "readmatrix" or "readcell" function.
For more information, you can take reference from the following link:
Hope this will help!

1 Comment

Thank you very much! 'readmatrix' works perfectly. If I may ask one more thing? The column I want to read from the Excel file has a title, and the number of data in it is variable. How can I manage to read from the second cell and read all the rest of the data from the column? Thanks in advance!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!