简体   繁体   English

使用MATLAB从csv文件读取字符串列

[英]Read column of string from csv file with MATLAB

I have the following data in a csv file: 我在csv文件中包含以下数据:

00:1A:1E:35:81:01,  -36,    -37,    -36
00:1A:1E:35:9D:61,  -69,    -69,    -69
00:1A:1E:35:7E:C1,  -95,    -95,    -71
00:1A:1E:35:9D:65,  -66,    -67,    -67
00:1A:1E:35:9D:60,  -67,    -68,    -68
00:1A:1E:35:9D:63,  -66,    -68,    -68

I am unable to read first column with MATLAB, which contain strings. 我无法使用MATLAB读取第一列,其中包含字符串。

You can use 您可以使用

xlsread(file.csv); 

instead of csvread. 而不是csvread。 It returns [num, txt, raw], where num contains all cells parsed to double (NaN where it was not possible), txt all cells as text ('' where conversion to num succeeded) and raw with all cells as strings. 它返回[num,txt,raw],其中num包含所有被解析为double的单元格(不可能的情况下为NaN),将所有单元格都以文本形式txt(成功转换为num的txt),并将raw的所有单元格都作为字符串。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM