简体   繁体   English

Matlab从Excel提取数据

[英]Matlab extracting data from excel

I have to read data from one column of excel where begins from A3 an incrementing like this: 我必须从A3开始的excel的一列中读取数据,如下所示:

0,-4.687500e-04,
1,-4.687500e-04,
2,-3.125000e-04,
3,-3.125000e-04,
4,1.562500e-04,
.
.
.

Number of data set is about 1400. How can I extract and save sequence number and the variable between the commas seperately? 数据集的数量大约为1400。如何分别提取和保存序列号和逗号之间的变量?

Use the textscan command and set the ',' as delimiter. 使用textscan命令并将','设置为定界符。

filename = %name of the file;
delimiter = {','};
startRow = 3;
fileID = fopen(filename,'r');
formatSpec = '%f%f[^\n\r]';
dataArray = textscan(fileID, formatSpec, 'Delimiter', delimiter, 'TextType','string', 'HeaderLines' ,startRow-1, 'ReturnOnError', false, 'EndOfLine','\r\n');
fclose(fileID);

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

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