MATLAB 如何在 Linux 上的 Matlab 中从 csv 中获取数据? xlsread 和导入数据

问题描述 投票:0回答:1

我有一个脚本可以使用

xlsread
分析来自 csv 的数据,但我需要在 Linux 上运行该脚本,而我目前使用的是 Windows10,所以
xlsread
不起作用。我尝试使用“基本”参数,但这不起作用。

data = xlsread("set1.csv"); % this extracts data that are integers or binary (TRUE/FALSE)
[~, data_id] = xlsread("set1.csv","A2:A10"); % this extracts the first column, which has subject IDs which are strings

我尝试使用

importdata
,它给了我一个带有
data
textdata
的结构,但是(a)我不知道为什么
data
只有2列(数字类型),即使有更多和 (b) textdata 将所有列数据作为字符串,但是我原始 csv 中的标题与 textdata 中的列不匹配:标题都应用于第一列,因此第一列具有所有标题,以逗号分隔,其他列没有标题。

我希望能够使用类似于

xlsread
在 Linux 中运行的东西从我的 csv 中获取数据。我用
readtable
readmatrix
readcell
importdata
环顾四周,但我没有找到任何能给我我想要的东西,因为我的 .csv 中的数据是混合类型:字符串、整数、二进制。

matlab csv xlsread importdata
1个回答
0
投票

使用工具条上的导入工具。然后,您可以生成运行的代码以导入您选择的数据。

© www.soinside.com 2019 - 2024. All rights reserved.