为什么我不能打开csv从matlab脚本生活吗?

5视图(30天)
你好,我是新手,所以这是maybesomething基本,但是我想迭代槽一个文件夹 . csv 和打开 readmtrix () 但是我有 错误使用 readmatrix ( 第146行 )将一个字符串标量或字符向量参数名称 对于这个错误。
这是我的代码:
路径= uigetdir ();
folder_read = dir (strcat(路径,' \ \扩展路径\ \ * . csv”));
i = 1:元素个数(folder_read)
Data = readmatrix (folder_read(我). name, 1, 0);%这是错误的。
结束;
当我类型控制台> >类(folder_read (I) . name)我:ans =“字符”
我需要做什么来让它工作吗?
2的评论

登录置评。

接受的答案

沃尔特·罗伯森
沃尔特·罗伯森 2021年9月26日
你试图把csvread () readmatrix ()。csvread()允许您传递一个参数是跳过的行数,然后一个参数是跳过的列数。所以csvread(文件名,1,0)意味着,第一行是跳过。
在任何现代版的MATLAB,您应该能够使用
Data = readmatrix (folder_read (i) . name)
readmatrix()应该自动检测和丢弃任何变量名在第一行。
然而,我注意到您正在使用R2019a,之前作出一些改进阅读*()函数。你可能需要使用
Data = readmatrix (folder_read . name(我),“NumHeaderLines”1);
2的评论
沃尔特·罗伯森
沃尔特·罗伯森 2021年9月26日
路径= uigetdir ();
folder_read = dir (strcat(路径,' \ \扩展路径\ \ * . csv”));
文件名= fullfile ({folder_read。文件夹},{folder_read.name});
nfile =元素个数(文件名);
all_data =细胞(nfile, 1);
我= 1:nfile
文件名thisfile = {};
Data = readmatrix (thisfile“NumHeaderLines”1);
all_data{我}=数据;
结束;

登录置评。

更多的答案(0)

下载188bet金宝搏


释放

R2019a

社区寻宝

找到宝藏在MATLAB中央,发现社区如何帮助你!

开始狩猎!