Use isnan with input excel data containing a combination of strings and empty cells in a row
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Saeid
el 17 de Jun. de 2019
Respondida: Alex Mcaulley
el 17 de Jun. de 2019
When I read raw data from an excel file named INFILE.xls, I usually want to remove the free spaces between columns afterward and have a string array composed only of the existng text.
[num, str, raw]=xlsread(INFILE)
samplerow=raw(1,:)
The result is:
{'first string'} {'second string'} {[NaN]} {[NaN]} {[NaN]} {[NaN]} {'third string'} ...
I would like to then have a string array like this:
strArray={'first string'} {'second string'} {'third string'} ...
If I try to find and remove the NaN elements using isnan I receive the error message
All contents of the input cell array must be of the same data type.
How can I work aorund this?
0 comentarios
Respuesta aceptada
Alex Mcaulley
el 17 de Jun. de 2019
If you just want the text:
[num, str, raw] = xlsread(INFILE)
samplerow = str(1,:);
samplerow(cellfun(@isempty,samplerow)) = [];
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Characters and Strings 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!