Matlab Read .txt files
2 次查看(过去 30 天)
显示 更早的评论
Hello,
I have a Matlab txt file containing lines that I want to read as number but also the lines I want to read as text. For instance, my .txt file reads:
8
6
01
02
I need those "values" and for importing those in my code, I used importdata built in function. However, Matlab recognizes the third line of .txt file as 1 (number) and not as 01 (string).
How can I force Matlab to give me the string '01' and '02' in the 3rd and 4th row of txt file?
Thank you in advance
3 个评论
Walter Roberson
2021-5-6
If you are using a new enough release, use readlines() and then str2double() indexing with appropriate indices of lines you want to consider numeric.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Text Files 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!