??? In an assignment A(I) = B, the number of elements in B and I must be the same
1 次查看(过去 30 天)
显示 更早的评论
Good morning everyone,
I am attempting to make a matrix that lists the directory of all the text files within a folder:
if true
d = uigetdir(pwd, 'Select a folder.');
f = fullfile(d,'*txt');
files = dir(f);
l = length(files);
file = zeros(1,l);
for i = 1:l
file(i) = fullfile(d,files(i).name)
i = i+1;
end
end
But I continue to receive this error:
??? In an assignment A(I) = B, the number of elements in B and I must be the same.
Error in ==> open_ex at 9 file(1) = fullfile(d,files(1).name);
Please help, thank you in advance
0 个评论
采纳的回答
Tom
2013-6-20
Try using a cell array to store the file names:
file = cell(1,l);
for i = 1:l
file{i} = fullfile(d,files(i).name)
i = i+1;
end
end
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!