Error by using csvread

1 次查看(过去 30 天)
Antonio Jayena
Antonio Jayena 2015-3-24
Hi, when I use this code:
k=0;
num=0:1:400;
for k=1:num(end)
cad = [];
cad = 'scope_%d_1.csv';
ss = [];
ss = sprintf(cad,num(k));
i=0;
cont=0;
s = csvread('ss', 2, 0);
[fil,col]=size(s);
for i=1:fil
if ((s(i,2))< 0.5)&&(s(i+1,2)-(s(i,2))>2)
cont=cont+1;
if (cont==25)
display(s(i, 1));
break
end
end
end
end
Im getting this error and I dont know why:
Error using dlmread (line 120)
The file 'ss' could not be opened because: No such
file or directory
Error in csvread (line 48)
m=dlmread(filename, ',', r, c);
Error in Matlab (line 10)
s = csvread('ss', 2, 0);
Any idea?

回答(1 个)

Image Analyst
Image Analyst 2015-3-24
Don't put quotes around it - that makes it a string literal. Try is this way, with just the variable:
s = csvread(ss, 2, 0);
And it would be better to pick more descriptive variable names, like "filename" instead of ss.

类别

Help CenterFile Exchange 中查找有关 Model Import 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by