why am I getting this error ? Any help please

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일

0 개 추천

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일

1 개 추천

filename = file_list{i};
data_in = readtable( fullfile(path_n, filename) );

댓글 수: 5

I'm reading a '.Cmn' file and it now 'readtable' is not able to read the file.
for i = 1:length(file_list)
filename = file_list{i};
data_in = readtable(fullfile(path_n, filename));
Error using readtable
'.Cmn' is not a recognized file
extension. Unable to detect file type. To
read the file as a specific file type,
regardless of file extension, use the
'FileType' name-value pair.
Error in READ_MULTI_FILES (line 12)
data_in = readtable(fullfile(path_n,
filename));
Thank you for your continuous help @Walter Roberson
Im able to read single files of this extension nevertheless, the issue at hand is to be able to read more than one of these files at once in and plot.
i settled with this code which allows me to do that (see below) but having to read the content has been a challenge.
[file_list,path_n]=uigetfile('*.Cmn','Grab the files you want yo process','Multiselect', 'on');
if iscell(file_list) == 0
file_list =(file_list);
end
for i = 1:length(file_list)
filename = file_list{i};
data_in = readtable(fullfile(path_n, filename));
subject_id = 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');
end
[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

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Timetables에 대해 자세히 알아보기

제품

릴리스

R2022a

질문:

2022년 8월 9일

편집:

2022년 8월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by