Find empty cells in excel
28 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi! I am trying to read data from a specific column in excel, but want to stop my code when it meets an empty
Here is my code:
[~,~,raw] = xlsread('file_name');
if isempty(raw(6,1)) == 1
disp('empty')
else
disp('non-epmty')
end
And evry time the code displays 'non-empty' even though the cell raw(6,1) is filled.
Any suggestions why ???
1 comentario
Respuestas (3)
Stephen23
el 14 de Nov. de 2018
Editada: Stephen23
el 14 de Nov. de 2018
You used the wrong kind of indexing. You need to use curly braces:
isempty(raw{6,1})
^ ^
The difference is simple:
- () parentheses access the cells themselves.
- {} curly braces access the cell contents (which is what you want to check).
Read more:
2 comentarios
Stephen23
el 14 de Nov. de 2018
@John Rebbner: If the cell is not empty then you should check the actual content of that cell. It might contain an empty string or something else the Ecxel something puts in cells. If you upoad your file then someone can help you with that.
Guillaume
el 14 de Nov. de 2018
Have you checked what the content of raw actually is for cells that are empty in excel? In my version of matlab (2018b) with my version of excel (office 365), an empty excel cell is translated to NaN not an empty array in matlab, so testing for emptiness is not going to succeed. Testing for NaN would have more success (with isnan)
0 comentarios
Surendra Reddy Kovvuri
el 26 de Mzo. de 2021
Please try this below condition
~isempty(find(isnan(raw{6,1})))
Thank you
0 comentarios
Ver también
Categorías
Más información sobre Spreadsheets en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!