MATLAB Answers

How to read an excel spreadsheet ignoring text and comments

2 views (last 30 days)
Jorge Morales
Jorge Morales on 27 Nov 2019
Commented: Image Analyst on 28 Nov 2019
i'm working on a matlab app that read an excel file to get experimental data, the files i need to read have a lot of comments and text over the data, i would like to know if is possible to read a file in the same way matlab import data but by coding, detecting the columns with data and ignoring text, this is an example of the files i need to read.


Sign in to comment.

Answers (1)

dpb on 27 Nov 2019
The venerable xlsread will return numeric, text, and the raw data in separate locations.
Probably better is to use the detectImportOptions utility function and then its output to read the data as a table instead.
It would be far easier if you would attach a sample file; my eyes can't begin to even read the image plus there's nothing that can be done with it....


Show 2 older comments
Jorge Morales
Jorge Morales on 27 Nov 2019
yes, the detectImportOptions utility work perfectly i only specified the range where the data is and that's it, thank you
dpb on 28 Nov 2019
It can probably detect that for you automagically as well...
Image Analyst
Image Analyst on 28 Nov 2019
Jorge, try his suggestion:
[numbersOnly, stringsOnly, everything] = xlsread('HPPC_18650_29dnl.xlsx');
If you look at numbersOnly, you will see it is an array where the (1,1) element is the row with the topmost number and leftmost number. Any place in that range that is a string or blank will show up as a NAN. If you have several ranges of numbers, you'll have to extract those individually from the larger matrix. Note that the indexes don't necessarily match up with the same row and column in Excel.

Sign in to comment.

Sign in to answer this question.