How do I force all contents in the cell array out of the command "xlsread" to be strings?
Show older comments
So if I use the below command to read an Excel file,
[A, B, C] = xlsread('abc.xlsx');
C should be a cell array storing both numeric and text data.
The issue is that columns containing text are stored in the cell array as strings, and the columns that contains only numbers are stored as numbers, and a lot of the times, I don't know which is which before hand. Is there a way I can force all of them to be stored as strings?
Thanks.
Answers (1)
Azzi Abdelmalek
on 14 Apr 2015
n={ 12 ,'1' ,4 ,nan, 45 }
n(cellfun(@isnan,n))={''}
out=cellfun(@num2str,n,'uni',0)
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!