why am I getting this error ? Any help please

7 次查看(过去 30 天)
for i = 1:length(file_list)
filename = file_list(i);
data_in = readtable([path_n filename]);
Error using readtable
"filename" must be a string scalar or
character vector.
Error in READ_MULTI_FILES (line 10)
data_in = readtable([path_n filename]);

采纳的回答

Stephen Tete
Stephen Tete 2022-8-10
files = dir('*.Cmn');
for i = 1:length(files)
data1 = files(i).name;
f = fopen(data1);
data = textscan(f,'%f%f%f%f%f%f%f%f%f%f', 'headerlines',5,'Delimiter','');
fclose(f);
% GET DATE
MJ{i} = data{1};
MJ = {cat(1,MJ{:})};
MJ_date = MJ{1,1};
end

更多回答(1 个)

Walter Roberson
Walter Roberson 2022-8-9
filename = file_list{i};
data_in = readtable( fullfile(path_n, filename) );
  5 个评论
Walter Roberson
Walter Roberson 2022-8-9
[file_list, path_n] = uigetfile('*.Cmn','Grab the files you want yo process','Multiselect', 'on');
if isnumeric(file_list)
return; %user cancel
end
file_list = cellstr(file_list);
for i = 1:length(file_list)
filename = file_list{i};
data_in = readtable(fullfile(path_n, filename));
subject_id(1,i) = string(filename(1:end-4));
VTEC = data(:,9);
STEC = data(:,8);
time = hours(:,2);
[H,M,S] = hms(time);
scatter(H,VTEC, 'k', H,STEC,'o');
hold on
end
leg = reshape(subject_id + ["_V"; "_S"], 1, []);
legend(leg)
Stephen Tete
Stephen Tete 2022-8-10
编辑:Walter Roberson 2022-8-10
Thank you so much for the help.
i modified the previous suggestion (you gave in the link above) and this modification works perfectly for me
files = dir('*.Cmn');
for i = 1:length(files)
data1 = files(i).name;
f = fopen(data1);
data = textscan(f,'%f%f%f%f%f%f%f%f%f%f', 'headerlines',5,'Delimiter','');
fclose(f);
% GET DATE
MJ{i} = data{1};
MJ = {cat(1,MJ{:})};
MJ_date = MJ{1,1};
end

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Data Type Identification 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by