![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/939619/image.jpeg)
readtable decide which coloumns are read as string and which as number. xlsx file
4 次查看(过去 30 天)
显示 更早的评论
Hi
Im trying to read an xlsx table, but readtable gives me the wrong format. some of my coloums are read as numbers and not strings. Thereby returning a NAN instead of the string i needed. My question. is there a way to force the datatype on readtable?
here is an example of how my data is set together in my input table
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/939594/image.png)
after reading into readtable it looks like this
RT = readtable("file.xlsx")
and here is the output
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/939599/image.png)
0 个评论
采纳的回答
更多回答(1 个)
Peter Perkins
2022-3-24
Magnus, detectImportOptions and subsequent modifications on what it returns are what you are looking for. You can set any or all of the variable types, and a whole lot more.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!