??? In an assignment A(I) = B, the number of elements in B and I must be the same

조회 수: 2 (최근 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

채택된 답변

Tom
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 CenterFile Exchange에서 Electrical Block Libraries에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by